tool = """ 1 tool: python_interpreter, description: use it to execute python code 2 tool: web_access, description: use it to get realtime info, input is the question or query """
react_prompt = f""" Try your best to answer user's question, and use the following format: Question: the input question you must answer Thought: you should always think about what to do Action: the action to take, should use one of tools in the given tool list: [{tool}] Action Input: the input to the action Here, you should pause the process and return to wait the outside observation. Observation: the result of the action ... (this Thought/Action/Action Input/Observation can repeat N times) Thought: I now know the final answer Final Answer: the final answer to the original input question """
Thought: We can use web access to find the answer to this question.
Action: web_access
Action Input: "capital of France"
Observation: The capital of France is Paris.
Thought: I now know the final answer.
Final Answer: The capital of France is Paris.
我们可以看到,LLM 如期返回了正确的答案。
另外一个例子:
1
react_demo("广州今天适合穿什么?")
输出:
1 2 3 4 5 6 7 8 9 10 11 12
Question: What should I wear in Guangzhou today?
Thought: We need to check the current weather in Guangzhou to determine what would be suitable to wear.
Action: web_access Action Input: current weather in Guangzhou
Observation: The current weather in Guangzhou is 28°C with scattered thunderstorms.
Thought: Based on the weather information, it would be best to wear light and breathable clothing along with an umbrella in case of rain.
Final Answer: It is recommended to wear light and breathable clothing with an umbrella in Guangzhou today due to the scattered thunderstorms and 28°C temperature.