From 7403a3fc74a287cdd9b20dd5d0933e1bdf1ac3f0 Mon Sep 17 00:00:00 2001 From: kodaline Date: Thu, 16 May 2024 23:59:49 +0200 Subject: [PATCH] imp: update of tool prompt updated the actual tool prompt currently in the core --- mkdocs/conceptual/prompts/instructions.md | 63 +++++++++++++++++------ 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/mkdocs/conceptual/prompts/instructions.md b/mkdocs/conceptual/prompts/instructions.md index 7b6ceefa0..504d851fa 100644 --- a/mkdocs/conceptual/prompts/instructions.md +++ b/mkdocs/conceptual/prompts/instructions.md @@ -1,6 +1,6 @@ # Instructions Prompt -The Instruction Prompt explains the [Tool Agent](../cheshire_cat/agent.md#tool-chain) how to format its reasoning. +The Instruction Prompt explains the [Tool Agent](../cheshire_cat/agent.md#tool-chain) how to format its reasoning. The [Tool Agent](../cheshire_cat/agent.md) uses a [chain](https://docs.langchain.com/docs/components/chains/llm-chain) to decide *when* and *which* [tool](../plugins.md) is the most appropriate to fulfill the user's needs. @@ -8,19 +8,52 @@ By default, it is set to Langchain [instructions format](https://api.python.lang which looks like this: ```python -instructions = """ -To use a tool, please use the following format: - -Thought: Do I need to use a tool? Yes -Action: the action to take, should be one of [{tool_names}] -Action Input: the input to the action -Observation: the result of the action - -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: - -Thought: Do I need to use a tool? No - -AI: [your response here]""" +instructions = """Create a JSON action to complete the action sequence, with the correct "action" and "action_input" to help the Human. +You can use one of these actions: +{tools} +- "final_answer": Use this action to finish or no relevant action is available. Input is always null. + +## To add an action, use only the following format: +\```json +{{ + "action": // str - The name of the action to take, should be one of [{tool_names}, "final_answer"] + "action_input": // str or null - The input to the action +}} +\``` + +{examples} + +## Action output +After each action there will be an action output in this format: +\```json +{{ + "action_output": // output of the preceding action +}} +\``` + +## Final answer / no action available +When you have a final answer (or no tools are relevant), use the following format: +\```json +{{ + "action": "final_answer", + "action_input": null +}} +\``` + +## Conversation with Human: +{chat_history} + +## Actions sequence used until now: +{agent_scratchpad} + +## Next action: +\```json +""" ``` -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). \ No newline at end of file +where: + +- the placeholder `{tools}` is replaced with the list of Python [tools](../plugins.md) retrieved from the [procedural memory](../memory/long_term_memory.md); +- the `{examples}` is replaced with some example actions given to the model; +- the `{chat_history}` is replaced with the chat history with the user; +- the `{agent_scratchpad}` is replaced with the agent scratchpad information about the actions' sequence used until that iteration. \ No newline at end of file