Commit b886ea6b by 文靖昊

提示词修改,多agent测试

parent a3e8fb77
...@@ -76,7 +76,67 @@ Action: ...@@ -76,7 +76,67 @@ Action:
}} }}
``` ```
开始!始终以有效的单个操作的 JSON 对象回复。如有必要,请使用工具。格式为 Action:```$JSON_BLOB```然后 Observation 开始!始终以有效的单个操作的 JSON 对象回复。如有必要,请使用工具。格式为 Action:```$JSON_BLOB```然后 Observation,例如:
历史记录:
'''
'''
Question: 西宁市各区县谁的年平均降雨量大。
Thought:这个问题是关于西宁市各区县的年平均降雨量,为了更精确地回答问题,我们需要明确西宁市下辖的所有区县。
Action:
```
{{
"action": "administrative_division",
"action_input": {{
"input_text": "西宁市"
}}
}}
```
Observation: 根据行政区划信息,西宁市下辖的区县有:城东区、城中区、城西区、城北区、大通回族土族自治县、湟中区、湟源县。
Thought:现在我们已经知道了西宁市下辖的所有区县,可以将问题扩展为关于这些区县谁的年平均降雨量大。
Action:
```
{{
"action": "Final Answer",
"action_input": "青海省西宁市各区县谁的年平均降雨量大,具体包括城东区、城中区、城西区、城北区、大通回族土族自治县、湟中区、湟源县的年平均降雨量对比。"
}}
```
----------------
历史记录:
'''
Q: 对话背景。
A: 当前对话是关于化隆县的介绍。
'''
Question: 其年最高温是多少
Thought:这个问题是关于化隆县的年最高温,由于对话背景已经明确了是化隆县的介绍,所以我们可以直接利用这个信息来扩展问题。
Action:
```
{{
"action": "administrative_division",
"action_input": {{"input_text": "化隆县"}}
}}
```
Observation: 根据行政区划信息,化隆县属于青海省海东市。
Thought: 既然化隆县属于青海省海东市,我们可以将问题扩展为关于青海省海东市化隆县的年最高温是多少。
Action:
```
{{
"action": "Final Answer",
"action_input": "青海省海东市化隆县的年最高温是多少?"
}}
```
----------------
历史记录:
'''
'''
原问题: 介绍一下Nginx。
Thought:Thought:这个问题是关于Nginx的介绍,不涉及具体的行政区划信息,因此不需要使用administrative_division工具。我们可以直接返回问题。
Action:
```
{{
"action": "Final Answer",
"action_input": "介绍一下Nginx"
}}
```
""" """
......
...@@ -110,26 +110,28 @@ administrative_agent_executor = AgentExecutor(agent=administrative_agent, tools= ...@@ -110,26 +110,28 @@ administrative_agent_executor = AgentExecutor(agent=administrative_agent, tools=
agent_executor = AgentExecutor(agent=agent, tools=tools,verbose=True,handle_parsing_errors=True,return_intermediate_steps=True) agent_executor = AgentExecutor(agent=agent, tools=tools,verbose=True,handle_parsing_errors=True,return_intermediate_steps=True)
history = [] history = []
h1 = [] # h1 = []
h1.append("攸县年降雨量") # h1.append("对话背景")
h1.append("攸县年雨量平均为30ml") # h1.append("当前对话是关于庄浪县的介绍")
history.append(h1) # history.append(h1)
h1 = [] # h1 = []
h1.append("长沙县年降雨量") # h1.append("长沙县年降雨量")
h1.append("长沙县年雨量平均为50ml") # h1.append("长沙县年雨量平均为50ml")
history.append(h1) # history.append(h1)
# res = agent_executor.invoke({"input":"以下历史对话记录: "+prompt+"以下是问题:"+"攸县、长沙县、化隆县和大通县谁的年平均降雨量大"}) # res = agent_executor.invoke({"input":"以下历史对话记录: "+prompt+"以下是问题:"+"攸县、长沙县、化隆县和大通县谁的年平均降雨量大"})
res_a = administrative_agent_executor.invoke({"input":"西宁市各区县谁的年平均降雨量大","histories":history}) res_a = administrative_agent_executor.invoke({"input":"株洲市各个县的最高气温","histories":history})
print(res_a) print(res_a)
new_question = res_a['output']
# res = agent_executor.invoke({"input":"西宁市各区县年平均降雨量","histories":history}) print(new_question)
#
# print(res) res = agent_executor.invoke({"input":new_question,"histories":history})
# docs_json = []
# for step in res["intermediate_steps"]: print(res)
# if "rag_query" ==step[0].tool: docs_json = []
# j = json.loads(step[1]["参考文档"], strict=False) for step in res["intermediate_steps"]:
# docs_json.extend(j) if "rag_query" ==step[0].tool:
# print(docs_json) j = json.loads(step[1]["参考文档"], strict=False)
docs_json.extend(j)
print(docs_json)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment