|
1 | 1 | # Instructions Prompt |
2 | 2 |
|
3 | | -The Instruction Prompt explains the [Tool Agent](../cheshire_cat/agent.md#tool-chain) how to format its reasoning. |
| 3 | +The Instruction Prompt explains the [Tool Agent](../cheshire_cat/agent.md#tool-chain) how to format its reasoning. |
4 | 4 | The [Tool Agent](../cheshire_cat/agent.md) uses a [chain](https://docs.langchain.com/docs/components/chains/llm-chain) |
5 | 5 | to decide *when* and *which* [tool](../plugins.md) is the most appropriate to fulfill the user's needs. |
6 | 6 |
|
7 | 7 | By default, it is set to Langchain [instructions format](https://api.python.langchain.com/en/latest/agents/langchain.agents.conversational.base.ConversationalAgent.html?highlight=prompt%20format_instruction) |
8 | 8 | which looks like this: |
9 | 9 |
|
10 | 10 | ```python |
11 | | -instructions = """ |
12 | | -To use a tool, please use the following format: |
13 | | -
|
14 | | -Thought: Do I need to use a tool? Yes |
15 | | -Action: the action to take, should be one of [{tool_names}] |
16 | | -Action Input: the input to the action |
17 | | -Observation: the result of the action |
18 | | -
|
19 | | -When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format: |
20 | | -
|
21 | | -Thought: Do I need to use a tool? No |
22 | | -
|
23 | | -AI: [your response here]""" |
| 11 | +instructions = """Create a JSON action to complete the action sequence, with the correct "action" and "action_input" to help the Human. |
| 12 | +You can use one of these actions: |
| 13 | +{tools} |
| 14 | +- "final_answer": Use this action to finish or no relevant action is available. Input is always null. |
| 15 | +
|
| 16 | +## To add an action, use only the following format: |
| 17 | +\```json |
| 18 | +{{ |
| 19 | + "action": // str - The name of the action to take, should be one of [{tool_names}, "final_answer"] |
| 20 | + "action_input": // str or null - The input to the action |
| 21 | +}} |
| 22 | +\``` |
| 23 | +
|
| 24 | +{examples} |
| 25 | +
|
| 26 | +## Action output |
| 27 | +After each action there will be an action output in this format: |
| 28 | +\```json |
| 29 | +{{ |
| 30 | + "action_output": // output of the preceding action |
| 31 | +}} |
| 32 | +\``` |
| 33 | +
|
| 34 | +## Final answer / no action available |
| 35 | +When you have a final answer (or no tools are relevant), use the following format: |
| 36 | +\```json |
| 37 | +{{ |
| 38 | + "action": "final_answer", |
| 39 | + "action_input": null |
| 40 | +}} |
| 41 | +\``` |
| 42 | +
|
| 43 | +## Conversation with Human: |
| 44 | +{chat_history} |
| 45 | +
|
| 46 | +## Actions sequence used until now: |
| 47 | +{agent_scratchpad} |
| 48 | +
|
| 49 | +## Next action: |
| 50 | +\```json |
| 51 | +""" |
24 | 52 | ``` |
25 | 53 |
|
26 | | -where the placeholder `{tool_names}` is replaced with the list of Python [tools](../plugins.md) retrieved from the [procedural memory](../memory/long_term_memory.md). |
| 54 | +where: |
| 55 | + |
| 56 | +- the placeholder `{tools}` is replaced with the list of Python [tools](../plugins.md) retrieved from the [procedural memory](../memory/long_term_memory.md); |
| 57 | +- the `{examples}` is replaced with some example actions given to the model; |
| 58 | +- the `{chat_history}` is replaced with the chat history with the user; |
| 59 | +- the `{agent_scratchpad}` is replaced with the agent scratchpad information about the actions' sequence used until that iteration. |
0 commit comments