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
031dfa1e
Commit
031dfa1e
authored
Nov 27, 2024
by
tinywell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1设备传感器数量查询接口接入;问题类型识别参数说明优化;工具返回数据结构精简
parent
a086b59c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
12 deletions
+49
-12
http_tools.py
src/agent/http_tools.py
+1
-1
tool_monitor.py
src/agent/tool_monitor.py
+0
-0
tool_rate.py
src/agent/tool_rate.py
+24
-0
api.py
src/controller/api.py
+1
-1
run_tool_picker_monitor.py
test/run_tool_picker_monitor.py
+16
-6
run_tool_picker_warn.py
test/run_tool_picker_warn.py
+7
-4
No files found.
src/agent/http_tools.py
View file @
031dfa1e
...
@@ -161,7 +161,7 @@ class MonitorClient(BaseHttpClient):
...
@@ -161,7 +161,7 @@ class MonitorClient(BaseHttpClient):
"deviceType"
:
device_type
"deviceType"
:
device_type
}
}
)
)
return
BaseResponse
[
Lis
t
](
**
data
)
return
BaseResponse
[
Dic
t
](
**
data
)
# 示例:添加新的数据接口客户端
# 示例:添加新的数据接口客户端
class
RateClient
(
BaseHttpClient
):
class
RateClient
(
BaseHttpClient
):
...
...
src/agent/tool_monitor.py
View file @
031dfa1e
This diff is collapsed.
Click to expand it.
src/agent/tool_rate.py
View file @
031dfa1e
...
@@ -124,6 +124,20 @@ class RegionRateTool(BaseRateTool):
...
@@ -124,6 +124,20 @@ class RegionRateTool(BaseRateTool):
for
item
in
df
.
resultdata
:
for
item
in
df
.
resultdata
:
rate_date
=
self
.
_extract_rate_data
(
item
)
rate_date
=
self
.
_extract_rate_data
(
item
)
result_data
.
append
(
rate_date
)
result_data
.
append
(
rate_date
)
sorted_data
=
[
rate_date
[
0
]]
if
len
(
result_data
)
>
1
:
sorted_data
.
extend
(
sorted
(
result_data
[
1
:],
key
=
lambda
x
:
x
[
'在线率'
]))
# 将数据改成表格形式,表头提取之后,数据一行行显示
table_header
=
list
(
result_data
[
0
]
.
keys
())
table_data
=
[]
for
item
in
result_data
:
table_data
.
append
(
list
(
item
.
values
()))
result_data
=
{
'table_header'
:
table_header
,
'table_data'
:
table_data
}
data
=
{
data
=
{
'region'
:
region_name
,
'region'
:
region_name
,
...
@@ -161,6 +175,16 @@ class RegionRateTool(BaseRateTool):
...
@@ -161,6 +175,16 @@ class RegionRateTool(BaseRateTool):
self
.
logger
.
debug
(
f
"查询结果: {df.resultdata}"
)
self
.
logger
.
debug
(
f
"查询结果: {df.resultdata}"
)
# markdown = self.to_markdown(df.resultdata)
# markdown = self.to_markdown(df.resultdata)
table_header
=
list
(
result_data
[
0
]
.
keys
())
table_data
=
[]
for
item
in
result_data
:
table_data
.
append
(
list
(
item
.
values
()))
result_data
=
{
'table_header'
:
table_header
,
'table_data'
:
table_data
}
data
=
{
data
=
{
'region'
:
region_name
,
'region'
:
region_name
,
'region_code'
:
code
,
'region_code'
:
code
,
...
...
src/controller/api.py
View file @
031dfa1e
...
@@ -26,7 +26,7 @@ DEFAULT_CONFIG = {
...
@@ -26,7 +26,7 @@ DEFAULT_CONFIG = {
"API_BASE"
:
"http://192.168.10.14:8000/v1"
,
"API_BASE"
:
"http://192.168.10.14:8000/v1"
,
"TOOL_BASE_URL"
:
"http://localhost:5001"
,
"TOOL_BASE_URL"
:
"http://localhost:5001"
,
"API_KEY"
:
"xxxxxxxxxxxxx"
,
"API_KEY"
:
"xxxxxxxxxxxxx"
,
"LOG_LEVEL"
:
"
DEBUG
"
"LOG_LEVEL"
:
"
INFO
"
}
}
def
get_config
(
key
:
str
,
args
:
Optional
[
argparse
.
Namespace
]
=
None
)
->
str
:
def
get_config
(
key
:
str
,
args
:
Optional
[
argparse
.
Namespace
]
=
None
)
->
str
:
...
...
test/run_tool_picker_monitor.py
View file @
031dfa1e
...
@@ -80,10 +80,20 @@ def run_examples():
...
@@ -80,10 +80,20 @@ def run_examples():
"expected"
:
{
"expected"
:
{
"tool"
:
"monitor_points_query"
,
"tool"
:
"monitor_points_query"
,
"params"
:
{
"params"
:
{
"key"
:
"甘肃省陇南市"
"key"
:
"甘肃省"
}
}
},{
"query"
:
"贵阳市的雨量传感器有多少"
,
"expected"
:
{
"tool"
:
"monitor_points_query"
,
"params"
:
{
"key"
:
"贵阳市"
,
"device_type"
:
"雨量"
,
"query_type"
:
"2"
,
}
}
}
}
}
},
]
]
# 为每个测试案例创建一个表格
# 为每个测试案例创建一个表格
...
@@ -120,10 +130,10 @@ def run_examples():
...
@@ -120,10 +130,10 @@ def run_examples():
"✓"
if
expected_value
==
actual_value
else
"✗"
"✓"
if
expected_value
==
actual_value
else
"✗"
)
)
# run tool
#
#
run tool
tool
=
tools_dict
[
actual_tool
]
#
tool = tools_dict[actual_tool]
result
=
tool
.
invoke
(
result
[
"params"
])
#
result = tool.invoke(result["params"])
print
(
result
)
#
print(result)
except
Exception
as
e
:
except
Exception
as
e
:
table
.
add_row
(
"错误"
,
""
,
str
(
e
),
"✗"
)
table
.
add_row
(
"错误"
,
""
,
str
(
e
),
"✗"
)
...
...
test/run_tool_picker_warn.py
View file @
031dfa1e
...
@@ -44,6 +44,7 @@ def run_examples():
...
@@ -44,6 +44,7 @@ def run_examples():
"start_time"
:
"2024-04-01 00:00:00"
,
"start_time"
:
"2024-04-01 00:00:00"
,
"end_time"
:
"2024-05-31 23:59:59"
,
"end_time"
:
"2024-05-31 23:59:59"
,
"region_name"
:
"甘肃省"
,
"region_name"
:
"甘肃省"
,
"query_type"
:
"1"
,
}
}
}
}
},{
},{
...
@@ -64,6 +65,7 @@ def run_examples():
...
@@ -64,6 +65,7 @@ def run_examples():
"start_time"
:
"2024-01-01 00:00:00"
,
"start_time"
:
"2024-01-01 00:00:00"
,
"end_time"
:
"2024-12-31 23:59:59"
,
"end_time"
:
"2024-12-31 23:59:59"
,
"region_name"
:
"甘肃省"
,
"region_name"
:
"甘肃省"
,
"query_type"
:
"2"
,
}
}
}
}
},{
},{
...
@@ -74,6 +76,7 @@ def run_examples():
...
@@ -74,6 +76,7 @@ def run_examples():
"start_time"
:
"2024-01-01 00:00:00"
,
"start_time"
:
"2024-01-01 00:00:00"
,
"end_time"
:
"2024-06-30 23:59:59"
,
"end_time"
:
"2024-06-30 23:59:59"
,
"region_name"
:
"甘肃省"
,
"region_name"
:
"甘肃省"
,
"query_type"
:
"1"
,
}
}
}
}
}
}
...
@@ -113,11 +116,11 @@ def run_examples():
...
@@ -113,11 +116,11 @@ def run_examples():
"✓"
if
expected_value
==
actual_value
else
"✗"
"✓"
if
expected_value
==
actual_value
else
"✗"
)
)
tool
=
tool_dict
[
result
[
"tool"
]]
#
tool = tool_dict[result["tool"]]
params
=
result
[
"params"
]
#
params = result["params"]
result
=
tool
.
invoke
(
params
)
#
result = tool.invoke(params)
print
(
result
)
#
print(result)
except
Exception
as
e
:
except
Exception
as
e
:
table
.
add_row
(
"错误"
,
""
,
str
(
e
),
"✗"
)
table
.
add_row
(
"错误"
,
""
,
str
(
e
),
"✗"
)
...
...
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