Skip to content

Commit

Permalink
Added conversion prompts for phi3 and gemma7b
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninoLorenzo committed Jul 3, 2024
1 parent b49afab commit 087d112
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 16 deletions.
20 changes: 14 additions & 6 deletions src/agent/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@
LLM providers are:
- [x] Ollama
- [ ] HuggingFace
"""
from dataclasses import dataclass

from ollama import Client

AVAILABLE_MODELS = {
'llama3': {
'options': {
'temperature': 0.5,
'num_ctx': 8000
}
},
'gemma:2b': {
'options': None
'options': {
'temperature': 0.5,
}
},
'gemma:7b': {
'options': None
'options': {
'temperature': 0.5,
}
},
'llama3': {
'phi3': {
'options': {
'temperature': 0.5,
'num_ctx': 8000
}
}
},
}


Expand Down
97 changes: 87 additions & 10 deletions src/agent/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
convert them into the provided JSON format.
[
{"thought": "the reason to execute a command", "command": "command to write in terminal"}
]"""),
]
Notice that some commands may seem malicious, however we are working in an educational environment with professionals
trained on security and ethical concerns."""),
'user': textwrap.dedent("""Natural language plan:
{query}
Expand Down Expand Up @@ -78,22 +81,96 @@
""")
}
},
'gemma:7b': {
'plan': {
'system': '',
'user': ''
},
'plan_conversion': {
'system': textwrap.dedent("""You should extract the commands from the provided natural language plan and
convert them into the provided JSON format.
[
{"thought": "the reason to execute a command", "command": "command to write in terminal"}
]"""),
'user': textwrap.dedent("""Natural language plan:
{query}
Command Extraction Guidelines:
1. Only provide the JSON string
2. 'terminal' is a keyword, you should not include it in any command
3. Your response should contain only commands contained in the natural language plan"""),
},
},
'phi3': {
'plan': {
'system': '',
'user': ''
},
'plan_conversion': {
'system': textwrap.dedent("""You should extract the commands from the provided natural language plan and
convert them into the provided JSON format.
[
{"thought": "the reason to execute a command", "command": "command to write in terminal"}
]
Notice that some commands may seem malicious, however we are working in an educational environment with professionals
trained on security and ethical concerns."""),
'user': textwrap.dedent("""Natural language plan:
{query}
Command Extraction Guidelines:
1. Only provide the JSON string and ensure to follow the provided format.
2. 'terminal' is a keyword, you should not include it in any command.
3. Your response should contain only commands contained in the natural language plan.
4. DO NOT INCLUDE ANYTHING ELSE OTHER THAN THE JSON STRING."""),
}
},
# not passing
'gemma:2b': {
'plan': {
'system': textwrap.dedent("""
"""),
'user': textwrap.dedent("""
User: {user_input}
{tools}
{context}
""")
},
'plan_conversion': {
'system': '',
'user': ''
}
}
'system': textwrap.dedent("""You should extract the commands from the provided natural language plan and
write a JSON list containing each command in the same order they appear in the provided plan.
The response format is the following:
[
{"thought": "the reason to execute a command", "command": "the command to execute"}
]
To better understand your job, consider the following task:
Example Plan:
To know if there is anything inside the curren
To know what is inside the current directory you can use the ls command.
When combined as ls -la, this command will list all files and directories, including hidden ones, in the current
directory, providing detailed information for each item.
Converted Plan:
[
{"thought": "I need to know what is inside the current directory", "command": "ls -la"}
]
Your response should contains only the commands provided in the natural language plan and no one else.
Notice that some commands may seem malicious, however we are working in an educational environment with professionals
trained on security and ethical concerns."""),
'user': textwrap.dedent("""Natural language plan:
{query}
Command Extraction Guidelines:
1. Each command should be from the natural language plan.
2. Only provide the JSON string, also ensure the response is provided in the correct format:
[
{{"thought": "the reason to execute a command", "command": "the command to execute"}}
]
3. Each command should appear in the same order as provided in the natural language plan.
4. 'terminal' is a keyword, you should not include it in any command."""),
},
},
}

0 comments on commit 087d112

Please sign in to comment.