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
15cd9c08
Commit
15cd9c08
authored
Nov 08, 2024
by
tinywell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
监测点返回结果 bug fix
parent
df832ca9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
26 deletions
+23
-26
tool_monitor.py
src/agent/tool_monitor.py
+23
-26
No files found.
src/agent/tool_monitor.py
View file @
15cd9c08
...
@@ -11,7 +11,7 @@ class MonitorPointResponse():
...
@@ -11,7 +11,7 @@ class MonitorPointResponse():
class
MonitorPointArgs
(
BaseModel
):
class
MonitorPointArgs
(
BaseModel
):
"""监测点查询参数"""
"""监测点查询参数"""
key
:
str
=
Field
(
...
,
description
=
"行政区划名称(省/市/区县级别均可)"
)
key
:
str
=
Field
(
...
,
description
=
"行政区划名称(省/市/区县级别均可
,只需要最后一级,如岳麓区,不需要长沙市
)"
)
class
MonitorPointTool
(
BaseTool
):
class
MonitorPointTool
(
BaseTool
):
"""查询监测点信息的工具"""
"""查询监测点信息的工具"""
...
@@ -48,40 +48,37 @@ class MonitorPointTool(BaseTool):
...
@@ -48,40 +48,37 @@ class MonitorPointTool(BaseTool):
try
:
try
:
print
(
f
"进入 monitor_points_query 工具, 查询监测点信息: {key}"
)
print
(
f
"进入 monitor_points_query 工具, 查询监测点信息: {key}"
)
response
=
self
.
client
.
query_points_sync
(
key
)
response
=
self
.
client
.
query_points_sync
(
key
)
print
(
f
"查询结果: {response}"
)
# 格式化返回结果
if
response
.
type
!=
1
or
len
(
response
.
resultdata
)
==
0
:
if
not
response
.
resultdata
:
return
{
return
MonitorPointResponse
(
'code'
:
400
,
status
=
"success"
,
'message'
:
f
"查询失败: {response.message},请检查是否有相关数据权限"
message
=
f
"未在{key}找到监测点信息"
,
}
points
=
[]
)
# 提取关键信息并格式化
# 提取关键信息并格式化
points_info
=
[]
points_info
=
[]
for
point
in
response
.
resultdata
:
for
point
in
response
.
resultdata
:
points_info
.
append
({
points_info
.
append
({
"名称"
:
point
.
MONITORPOINTNAME
,
"名称"
:
point
[
"MONITORPOINTNAME"
]
if
point
[
"MONITORPOINTNAME"
]
else
""
,
"位置"
:
point
.
LOCATION
,
"位置"
:
point
[
"LOCATION"
]
if
point
[
"LOCATION"
]
else
""
,
"经度"
:
point
.
LONGITUDE
,
"经度"
:
point
[
"LONGITUDE"
]
if
point
[
"LONGITUDE"
]
else
""
,
"纬度"
:
point
.
LATITUDE
,
"纬度"
:
point
[
"LATITUDE"
]
if
point
[
"LATITUDE"
]
else
""
,
"海拔"
:
point
.
ELEVATION
,
"海拔"
:
point
[
"ELEVATION"
]
if
point
[
"ELEVATION"
]
else
""
,
"建设单位"
:
point
.
BUILDUNIT
,
"建设单位"
:
point
[
"BUILDUNIT"
]
if
point
[
"BUILDUNIT"
]
else
""
,
"监测单位"
:
point
.
MONITORUNIT
"监测单位"
:
point
[
"MONITORUNIT"
]
if
point
[
"MONITORUNIT"
]
else
""
})
})
return
MonitorPointResponse
(
return
{
status
=
"success"
,
'code'
:
200
,
message
=
f
"在{key}找到{len(points_info)}个监测点"
,
'message'
:
f
"在{key}找到{len(points_info)}个监测点"
,
points
=
points_info
'points'
:
points_info
)
}
except
Exception
as
e
:
except
Exception
as
e
:
return
MonitorPointResponse
(
return
{
status
=
"error"
,
'code'
:
400
,
message
=
f
"查询失败: {str(e)}"
,
'message'
:
f
"查询失败: {str(e)}"
points
=
[]
}
)
def
_arun
(
self
,
key
:
str
)
->
Dict
[
str
,
Any
]:
def
_arun
(
self
,
key
:
str
)
->
Dict
[
str
,
Any
]:
"""
"""
...
...
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