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
44bdb2dd
Commit
44bdb2dd
authored
Nov 28, 2024
by
tinywell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
补充监测点查询 warnlevel 参数;优化 prompt 改进数量问题回答效果
parent
0823b3f5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
http_tools.py
src/agent/http_tools.py
+3
-1
tool_monitor.py
src/agent/tool_monitor.py
+11
-9
tool_picker.py
src/server/tool_picker.py
+6
-1
No files found.
src/agent/http_tools.py
View file @
44bdb2dd
...
@@ -109,7 +109,7 @@ class MonitorClient(BaseHttpClient):
...
@@ -109,7 +109,7 @@ class MonitorClient(BaseHttpClient):
def
query_points_sync
(
self
,
key
:
str
,
def
query_points_sync
(
self
,
key
:
str
,
year
:
str
,
monitor_type
:
str
,
three_d_model
:
str
,
ortho_image
:
str
,
year
:
str
,
monitor_type
:
str
,
three_d_model
:
str
,
ortho_image
:
str
,
disaster_threat_people_range_start
:
str
,
disaster_threat_people_range_end
:
str
,
disaster_threat_people_range_start
:
str
,
disaster_threat_people_range_end
:
str
,
disaster_scale_start
:
str
,
disaster_scale_end
:
str
,
device_type
:
str
)
->
BaseResponse
[
List
]:
disaster_scale_start
:
str
,
disaster_scale_end
:
str
,
warn_level
:
str
,
device_type
:
str
)
->
BaseResponse
[
List
]:
"""同步查询监测点信息"""
"""同步查询监测点信息"""
params
=
{
params
=
{
"key"
:
key
,
"key"
:
key
,
...
@@ -117,9 +117,11 @@ class MonitorClient(BaseHttpClient):
...
@@ -117,9 +117,11 @@ class MonitorClient(BaseHttpClient):
"MONITORTYPE"
:
monitor_type
,
"MONITORTYPE"
:
monitor_type
,
"MODELEXIST"
:
three_d_model
,
"MODELEXIST"
:
three_d_model
,
"DOMEXIST"
:
ortho_image
,
"DOMEXIST"
:
ortho_image
,
"WARNLEVEL"
:
warn_level
,
"STARTTHREATSPOPULATION"
:
disaster_threat_people_range_start
,
"STARTTHREATSPOPULATION"
:
disaster_threat_people_range_start
,
"ENDTHREATSPOPULATION"
:
disaster_threat_people_range_end
,
"ENDTHREATSPOPULATION"
:
disaster_threat_people_range_end
,
"STARTDISASTERSCALE"
:
disaster_scale_start
,
"STARTDISASTERSCALE"
:
disaster_scale_start
,
"ENDDISASTERSCALE"
:
disaster_scale_end
}
}
print
(
f
"查询参数: {params}"
)
print
(
f
"查询参数: {params}"
)
...
...
src/agent/tool_monitor.py
View file @
44bdb2dd
...
@@ -26,6 +26,7 @@ class MonitorPointArgs(BaseModel):
...
@@ -26,6 +26,7 @@ class MonitorPointArgs(BaseModel):
disaster_threat_people_range_end
:
str
=
Field
(
""
,
description
=
"灾害威胁人数范围结束值,如200,默认为空"
)
disaster_threat_people_range_end
:
str
=
Field
(
""
,
description
=
"灾害威胁人数范围结束值,如200,默认为空"
)
disaster_scale_start
:
str
=
Field
(
""
,
description
=
"灾害规模范围起始值,灾害为崩塌、滑坡、泥石流时表示体积,灾害为地面塌陷、地面沉降时表示面积,为地裂缝时表示长度,默认为空"
)
disaster_scale_start
:
str
=
Field
(
""
,
description
=
"灾害规模范围起始值,灾害为崩塌、滑坡、泥石流时表示体积,灾害为地面塌陷、地面沉降时表示面积,为地裂缝时表示长度,默认为空"
)
disaster_scale_end
:
str
=
Field
(
""
,
description
=
"灾害规模范围结束值,灾害为崩塌、滑坡、泥石流时表示体积,灾害为地面塌陷、地面沉降时表示面积,为地裂缝时表示长度,默认为空"
)
disaster_scale_end
:
str
=
Field
(
""
,
description
=
"灾害规模范围结束值,灾害为崩塌、滑坡、泥石流时表示体积,灾害为地面塌陷、地面沉降时表示面积,为地裂缝时表示长度,默认为空"
)
warn_level
:
str
=
Field
(
""
,
description
=
"预警等级,1、2、3、4、5,1-4分别对应红色、橙色、黄色、蓝色,5为无预警,默认为空"
)
device_type
:
str
=
Field
(
""
,
description
=
"设备类型或者传感器类型,当查询设备或传感器信息时需要(例如 加速度、位移、温度、湿度、裂缝计、雨量等),默认为空"
)
device_type
:
str
=
Field
(
""
,
description
=
"设备类型或者传感器类型,当查询设备或传感器信息时需要(例如 加速度、位移、温度、湿度、裂缝计、雨量等),默认为空"
)
...
@@ -35,7 +36,7 @@ class MonitorPointTool(BaseTool):
...
@@ -35,7 +36,7 @@ class MonitorPointTool(BaseTool):
description
:
str
=
"""查询指定行政区划的监测点信息。
description
:
str
=
"""查询指定行政区划的监测点信息。
可以查询任意省/市/区县级别的监测点数据,也可以通过灾害类型、灾害规模、灾害威胁人数范围、设备类型等条件查询。
可以查询任意省/市/区县级别的监测点数据,也可以通过灾害类型、灾害规模、灾害威胁人数范围、设备类型等条件查询。
输入参数为行政区划名称,如:湖南省、长沙市、岳麓区等。
输入参数为行政区划名称,如:湖南省、长沙市、岳麓区等。
返回该区域内的监测点列表,包含位置、经纬度等详细信息。
返回该区域内的监测点列表,包含位置、经纬度
、海拔、建设单位、监测单位、监测类型、有无三维模型、有无正射影像、威胁人数、规模等级
等详细信息。
还可以查询监测点下相关监测设备、传感器信息,比如设备数量、传感器数量等。
还可以查询监测点下相关监测设备、传感器信息,比如设备数量、传感器数量等。
"""
"""
args_schema
:
Type
[
BaseModel
]
=
MonitorPointArgs
args_schema
:
Type
[
BaseModel
]
=
MonitorPointArgs
...
@@ -57,7 +58,7 @@ class MonitorPointTool(BaseTool):
...
@@ -57,7 +58,7 @@ class MonitorPointTool(BaseTool):
def
_run
(
self
,
key
:
str
,
start_time
:
str
=
""
,
end_time
:
str
=
""
,
disaster_type
:
str
=
""
,
def
_run
(
self
,
key
:
str
,
start_time
:
str
=
""
,
end_time
:
str
=
""
,
disaster_type
:
str
=
""
,
three_d_model
:
str
=
""
,
ortho_image
:
str
=
""
,
three_d_model
:
str
=
""
,
ortho_image
:
str
=
""
,
disaster_threat_people_range_start
:
str
=
""
,
disaster_threat_people_range_end
:
str
=
""
,
disaster_threat_people_range_start
:
str
=
""
,
disaster_threat_people_range_end
:
str
=
""
,
disaster_scale_start
:
str
=
""
,
disaster_scale_end
:
str
=
""
,
device_type
:
str
=
""
,
disaster_scale_start
:
str
=
""
,
disaster_scale_end
:
str
=
""
,
warn_level
:
str
=
""
,
device_type
:
str
=
""
,
query_type
:
str
=
"points"
)
->
Dict
[
str
,
Any
]:
query_type
:
str
=
"points"
)
->
Dict
[
str
,
Any
]:
"""
"""
执行监测点查询
执行监测点查询
...
@@ -73,6 +74,7 @@ class MonitorPointTool(BaseTool):
...
@@ -73,6 +74,7 @@ class MonitorPointTool(BaseTool):
disaster_threat_people_range_end: 灾害威胁人数范围结束值
disaster_threat_people_range_end: 灾害威胁人数范围结束值
disaster_scale_start: 灾害规模范围起始值
disaster_scale_start: 灾害规模范围起始值
disaster_scale_end: 灾害规模范围结束值
disaster_scale_end: 灾害规模范围结束值
warn_level: 预警等级
device_type: 设备类型
device_type: 设备类型
query_type: 查询类型
query_type: 查询类型
Returns:
Returns:
...
@@ -95,7 +97,7 @@ class MonitorPointTool(BaseTool):
...
@@ -95,7 +97,7 @@ class MonitorPointTool(BaseTool):
return
self
.
_get_device_info
(
code
,
start_time
,
end_time
,
device_type
)
return
self
.
_get_device_info
(
code
,
start_time
,
end_time
,
device_type
)
else
:
else
:
year
=
start_time
.
split
(
"-"
)[
0
]
year
=
start_time
.
split
(
"-"
)[
0
]
return
self
.
_get_points_info
(
code
,
year
,
disaster_type
,
three_d_model
,
ortho_image
,
disaster_threat_people_range_start
,
disaster_threat_people_range_end
,
disaster_scale_start
,
disaster_scale_end
,
device_type
)
return
self
.
_get_points_info
(
code
,
year
,
disaster_type
,
three_d_model
,
ortho_image
,
disaster_threat_people_range_start
,
disaster_threat_people_range_end
,
disaster_scale_start
,
disaster_scale_end
,
warn_level
,
device_type
)
def
_get_device_info
(
self
,
code
:
str
,
start_time
:
str
=
""
,
end_time
:
str
=
""
,
device_type
:
str
=
""
):
def
_get_device_info
(
self
,
code
:
str
,
start_time
:
str
=
""
,
end_time
:
str
=
""
,
device_type
:
str
=
""
):
self
.
logger
.
info
(
f
"开始查询设备信息,区域: {key}"
)
self
.
logger
.
info
(
f
"开始查询设备信息,区域: {key}"
)
...
@@ -141,7 +143,7 @@ class MonitorPointTool(BaseTool):
...
@@ -141,7 +143,7 @@ class MonitorPointTool(BaseTool):
result
=
{
result
=
{
'code'
:
200
,
'code'
:
200
,
'
message
'
:
f
"在{key}找到{len(devices_info)}个设备信息, {len(sensors_info)}个传感器信息"
,
'
summary
'
:
f
"在{key}找到{len(devices_info)}个设备信息, {len(sensors_info)}个传感器信息"
,
# 'devices': {
# 'devices': {
# 'table_header': device_table_header,
# 'table_header': device_table_header,
# 'table_data': device_table_data
# 'table_data': device_table_data
...
@@ -163,14 +165,14 @@ class MonitorPointTool(BaseTool):
...
@@ -163,14 +165,14 @@ class MonitorPointTool(BaseTool):
def
_get_points_info
(
self
,
key
:
str
,
year
:
str
=
""
,
disaster_type
:
str
=
""
,
def
_get_points_info
(
self
,
key
:
str
,
year
:
str
=
""
,
disaster_type
:
str
=
""
,
three_d_model
:
str
=
""
,
ortho_image
:
str
=
""
,
three_d_model
:
str
=
""
,
ortho_image
:
str
=
""
,
disaster_threat_people_range_start
:
str
=
""
,
disaster_threat_people_range_end
:
str
=
""
,
disaster_threat_people_range_start
:
str
=
""
,
disaster_threat_people_range_end
:
str
=
""
,
disaster_scale_start
:
str
=
""
,
disaster_scale_end
:
str
=
""
,
device_type
:
str
=
""
):
disaster_scale_start
:
str
=
""
,
disaster_scale_end
:
str
=
""
,
warn_level
:
str
=
""
,
device_type
:
str
=
""
):
try
:
try
:
self
.
logger
.
info
(
f
"开始查询监测点信息,区域: {key}"
)
self
.
logger
.
info
(
f
"开始查询监测点信息,区域: {key}"
)
response
=
self
.
client
.
query_points_sync
(
key
,
year
,
response
=
self
.
client
.
query_points_sync
(
key
,
year
,
disaster_type
,
three_d_model
,
ortho_image
,
disaster_type
,
three_d_model
,
ortho_image
,
disaster_threat_people_range_start
,
disaster_threat_people_range_end
,
disaster_threat_people_range_start
,
disaster_threat_people_range_end
,
disaster_scale_start
,
disaster_scale_end
,
device_type
)
disaster_scale_start
,
disaster_scale_end
,
warn_level
,
device_type
)
self
.
logger
.
debug
(
f
"API响应: {response}"
)
self
.
logger
.
debug
(
f
"API响应: {response}"
)
if
response
.
type
!=
1
or
len
(
response
.
resultdata
)
==
0
:
if
response
.
type
!=
1
or
len
(
response
.
resultdata
)
==
0
:
...
@@ -216,12 +218,12 @@ class MonitorPointTool(BaseTool):
...
@@ -216,12 +218,12 @@ class MonitorPointTool(BaseTool):
table_data
=
[]
table_data
=
[]
for
item
in
points_info
:
for
item
in
points_info
:
table_data
.
append
(
list
(
item
.
values
()))
table_data
.
append
(
list
(
item
.
values
()))
if
len
(
table_data
)
>
5
0
:
if
len
(
table_data
)
>
20
0
:
table_data
=
table_data
[:
5
0
]
table_data
=
table_data
[:
20
0
]
table_data
.
append
([
"..."
])
table_data
.
append
([
"..."
])
result
=
{
result
=
{
'code'
:
200
,
'code'
:
200
,
'
message'
:
f
"在{key}找到{len(points_info)}个
监测点信息"
,
'
summary'
:
f
"在{key}找到{len(points_info)}个满足条件的
监测点信息"
,
'points'
:
{
'points'
:
{
'table_header'
:
table_header
,
'table_header'
:
table_header
,
'table_data'
:
table_data
'table_data'
:
table_data
...
...
src/server/tool_picker.py
View file @
44bdb2dd
...
@@ -88,7 +88,9 @@ RUNNER_SYSTEM_PROMPT_V0 = """
...
@@ -88,7 +88,9 @@ RUNNER_SYSTEM_PROMPT_V0 = """
请遵循以下规则:
请遵循以下规则:
- 工具执行结果中的数据必须使用 markdown 表格展示
- 工具执行结果中的数据必须使用 markdown 表格展示
- 确保数据的完整性, 不要遗漏数据
- 确保数据的完整性, 不要遗漏数据
- 表格中的数据只能来源于工具执行结果
- 表格中的数据只能来源于工具执行结果,不得添加或修改
- 涉及数量的问题(如个数、总数等),必须严格按照工具返回的结果数据回答,不得进行任何推断或估算
- 如果工具结果中没有相关数据,应明确告知无法得知具体数量,而不是给出推测的数字
"""
"""
...
@@ -136,6 +138,9 @@ class ToolRunner:
...
@@ -136,6 +138,9 @@ class ToolRunner:
if
"markdown"
in
result
:
if
"markdown"
in
result
:
table
=
result
[
"markdown"
]
table
=
result
[
"markdown"
]
del
result
[
"markdown"
]
del
result
[
"markdown"
]
if
"summary"
in
result
:
summary
=
result
[
"summary"
]
result
[
"summary"
]
=
f
"针对问题 {input},我们{summary}"
# LLM 解释结果
# LLM 解释结果
llm_start
=
time
.
time
()
llm_start
=
time
.
time
()
...
...
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