Skip to content

Commit 7403a3f

Browse files
committed
imp: update of tool prompt
updated the actual tool prompt currently in the core
1 parent 5fd1a09 commit 7403a3f

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed
Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,59 @@
11
# Instructions Prompt
22

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.
44
The [Tool Agent](../cheshire_cat/agent.md) uses a [chain](https://docs.langchain.com/docs/components/chains/llm-chain)
55
to decide *when* and *which* [tool](../plugins.md) is the most appropriate to fulfill the user's needs.
66

77
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)
88
which looks like this:
99

1010
```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+
"""
2452
```
2553

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

Comments
 (0)