Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
LAE
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
文靖昊
LAE
Commits
b886ea6b
Commit
b886ea6b
authored
7 months ago
by
文靖昊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提示词修改,多agent测试
parent
a3e8fb77
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
20 deletions
+82
-20
prompts.py
src/config/prompts.py
+61
-1
rag_agent_test.py
test/rag_agent_test.py
+21
-19
No files found.
src/config/prompts.py
View file @
b886ea6b
...
...
@@ -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"
}}
```
"""
...
...
This diff is collapsed.
Click to expand it.
test/rag_agent_test.py
View file @
b886ea6b
...
...
@@ -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
)
history
=
[]
h1
=
[]
h1
.
append
(
"攸县年降雨量
"
)
h1
.
append
(
"攸县年雨量平均为30ml
"
)
history
.
append
(
h1
)
h1
=
[]
h1
.
append
(
"长沙县年降雨量"
)
h1
.
append
(
"长沙县年雨量平均为50ml"
)
history
.
append
(
h1
)
#
h1 = []
# h1.append("对话背景
")
# h1.append("当前对话是关于庄浪县的介绍
")
#
history.append(h1)
#
h1 = []
#
h1.append("长沙县年降雨量")
#
h1.append("长沙县年雨量平均为50ml")
#
history.append(h1)
# 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
)
# res = agent_executor.invoke({"input":"西宁市各区县年平均降雨量","histories":history})
#
# print(res)
# docs_json = []
# for step in res["intermediate_steps"]:
# if "rag_query" ==step[0].tool:
# j = json.loads(step[1]["参考文档"], strict=False)
# docs_json.extend(j)
# print(docs_json)
new_question
=
res_a
[
'output'
]
print
(
new_question
)
res
=
agent_executor
.
invoke
({
"input"
:
new_question
,
"histories"
:
history
})
print
(
res
)
docs_json
=
[]
for
step
in
res
[
"intermediate_steps"
]:
if
"rag_query"
==
step
[
0
]
.
tool
:
j
=
json
.
loads
(
step
[
1
][
"参考文档"
],
strict
=
False
)
docs_json
.
extend
(
j
)
print
(
docs_json
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment