Improve system prompt documentation
This commit is contained in:
parent
4a99f8b8d8
commit
2933ed30d5
|
@ -186,7 +186,56 @@ Better ways to guide your LLM engine are:
|
|||
- If it 's about the task to solve: add all these details to the task. The task could be 100s of pages long.
|
||||
- If it's about how to use tools: the description attribute of your tools.
|
||||
|
||||
If after trying the above, you still want to change the system prompt, your new system prompt passed to `system_prompt` upon agent initialization needs to contain the following placeholders that will be used to insert certain automatically generated descriptions when running the agent:
|
||||
|
||||
### 3. Change the system prompt (generally not advised)
|
||||
|
||||
If above clarifications above are not sufficient, you can change the system prompt.
|
||||
|
||||
Let's see how it works. For example, let us check the default system prompt for the [`CodeAgent`] (below version is shortened by skipping zero-shot examples).
|
||||
|
||||
```python
|
||||
print(agent.system_prompt_template)
|
||||
```
|
||||
Here is what you get:
|
||||
```text
|
||||
You are an expert assistant who can solve any task using code blobs. You will be given a task to solve as best you can.
|
||||
To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.
|
||||
To solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.
|
||||
|
||||
At each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.
|
||||
Then in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.
|
||||
During each intermediate step, you can use 'print()' to save whatever important information you will then need.
|
||||
These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
|
||||
In the end you have to return a final answer using the `final_answer` tool.
|
||||
|
||||
Here are a few examples using notional tools:
|
||||
---
|
||||
{examples}
|
||||
|
||||
Above example were using notional tools that might not exist for you. On top of performing computations in the Python code snippets that you create, you only have access to these tools:
|
||||
|
||||
{{tool_descriptions}}
|
||||
|
||||
{{managed_agents_descriptions}}
|
||||
|
||||
Here are the rules you should always follow to solve your task:
|
||||
1. Always provide a 'Thought:' sequence, and a 'Code:\n```py' sequence ending with '```<end_code>' sequence, else you will fail.
|
||||
2. Use only variables that you have defined!
|
||||
3. Always use the right arguments for the tools. DO NOT pass the arguments as a dict as in 'answer = wiki({'query': "What is the place where James Bond lives?"})', but use the arguments directly as in 'answer = wiki(query="What is the place where James Bond lives?")'.
|
||||
4. Take care to not chain too many sequential tool calls in the same code block, especially when the output format is unpredictable. For instance, a call to search has an unpredictable return format, so do not have another tool call that depends on its output in the same block: rather output results with print() to use them in the next block.
|
||||
5. Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.
|
||||
6. Don't name any new variable with the same name as a tool: for instance don't name a variable 'final_answer'.
|
||||
7. Never create any notional variables in our code, as having these in your logs might derail you from the true variables.
|
||||
8. You can use imports in your code, but only from the following list of modules: {{authorized_imports}}
|
||||
9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
|
||||
10. Don't give up! You're in charge of solving the task, not providing directions to solve it.
|
||||
|
||||
Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000.
|
||||
```
|
||||
|
||||
As yo can see, there are placeholders like `"{{tool_descriptions}}"`: these will be used upon agent initialization to insert certain automatically generated descriptions of tools or managed agents.
|
||||
|
||||
So while you can overwrite this system prompt template by passing your custom prompt as an argument to the `system_prompt` parameter, your new system promptmust contain the following placeholders:
|
||||
- `"{{tool_descriptions}}"` to insert tool descriptions.
|
||||
- `"{{managed_agents_description}}"` to insert the description for managed agents if there are any.
|
||||
- For `CodeAgent` only: `"{{authorized_imports}}"` to insert the list of authorized imports.
|
||||
|
@ -205,10 +254,10 @@ agent = CodeAgent(
|
|||
)
|
||||
```
|
||||
|
||||
This also works with the ToolCallingAgent.
|
||||
This also works with the [`ToolCallingAgent`].
|
||||
|
||||
|
||||
### 3. Extra planning
|
||||
### 4. Extra planning
|
||||
|
||||
We provide a model for a supplementary planning step, that an agent can run regularly in-between normal action steps. In this step, there is no tool call, the LLM is simply asked to update a list of facts it knows and to reflect on what steps it should take next based on those facts.
|
||||
|
||||
|
|
Loading…
Reference in New Issue