赞
踩
System: Respond to the human as helpfully and accurately as possible. You have access to the following tools:
Calculator: Useful for when you need to calculate math problems, args: {\'calculation\': {\'description\': \'calculation to perform\', \'title\': \'Calculation\', \'type\': \'string\'}}
Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "action" values: "Final Answer" or Calculator
Provide only ONE action per $JSON_BLOB, as shown:
```
{
"action": $TOOL_NAME,
"action_input": $INPUT
}
```
Follow this format:
Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
"action": "Final Answer",
"action_input": "Final response to human"
}
Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation
Human: 34 * 34
(reminder to respond in a JSON blob no matter what)
Calculator: Useful for when you need to calculate math problems, args: {'calculation': {'description': 'calculation to perform', 'title': 'Calculation', 'type': 'string'}}
Human: 34 * 34\n\n\n(reminder to respond in a JSON blob no matter what)
- [
- {
- 'role': 'system',
- 'content': 'Answer the following questions as best as you can. You have access to the following tools:',
- 'tools': [
- {
- 'name': 'Calculator',
- 'description': 'Useful for when you need to calculate math problems',
- 'parameters': {
- 'calculation': {
- 'description': 'calculation to perform',
- 'type': 'string'
- }
- }
- }
- ]
- },
- {
- 'role': 'user',
- 'content': '34 * 34\n\n\n (reminder to respond in a JSON blob no matter what)'
- }
- ]
[{'role': 'system', 'content': 'Answer the following questions as best as you can. You have access to the following tools:', 'tools': [{'name': 'Calculator', 'description': 'Useful for when you need to calculate math problems', 'parameters': {'calculation': {'description': 'calculation to perform', 'type': 'string'}}}]}, {'role': 'user', 'content': '34 * 34\n\n\n (reminder to respond in a JSON blob no matter what)'}, {'role': 'user', 'content': '34 * 34'}, {'role': 'assistant', 'metadata': 'Calculator', 'content': " ```python\ntool_call(calculation='34*34')\n```"}]
==新增了两条信息==
{'role': 'user', 'content': '34 * 34'},
{'role': 'assistant', 'metadata': 'Calculator', 'content': " ```python\ntool_call(calculation='34*34')\n```"}
response = '\nAction: \n```\n{"action": "Calculator", "action_input": {"calculation": "34*34"}}\n```'
==此时prompt就是原始prompt==
==response就是ChatGLM生成的接下来要用到的Tool,也就是原始prompt里希望LLM返回的结果==
==这时候LLM还没有返回Final answer,所以要继续执行LLM==
'System: Respond to the human as helpfully and accurately as possible. You have access to the following tools:\n\nCalculator: Useful for when you need to calculate math problems, args: {\'calculation\': {\'description\': \'calculation to perform\', \'title\': \'Calculation\', \'type\': \'string\'}}\n\nUse a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).\n\nValid "action" values: "Final Answer" or Calculator\n\nProvide only ONE action per $JSON_BLOB, as shown:\n\n```\n{\n "action": $TOOL_NAME,\n "action_input": $INPUT\n}\n```\n\nFollow this format:\n\nQuestion: input question to answer\nThought: consider previous and subsequent steps\nAction:\n```\n$JSON_BLOB\n```\nObservation: action result\n... (repeat Thought/Action/Observation N times)\nThought: I know what to respond\nAction:\n```\n{\n "action": "Final Answer",\n "action_input": "Final response to human"\n}\n\nBegin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation\nHuman: 34 * 34\n\n\n
Action: \n```\n{"action": "Calculator", "action_input": {"calculation": "34*34"}}\n```\nObservation: 1156\nThought: \n
==这一段是新增的,增加了上一步Action的Tool的执行结果==
(reminder to respond in a JSON blob no matter what)'
得到1156
向self.history新增一条信息:
{'role': 'observation', 'content': '1156'}
入参:此时query是空,history是所有的历史
返回结果,新增如下两条信息:
{'role': 'user', 'content': ''}
{'role': 'assistant', 'metadata': '', 'content': '{\n " calculation": "34*34",\n " result": 1156\n}'}
response = '\nAction: \n```\n{"action": "Final Answer", "action_input": "{\\n \\" calculation\\": \\"34*34\\",\\n \\" result\\": 1156\\n}"}\n```'
0=新的prompt
1=response
{'input': '34 * 34', 'output': '{\n " calculation": "34*34",\n " result": 1156\n}'}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。