add more tools

pull/17608/head
fuwx 1 year ago
parent 2feb2fd533
commit bc04cfbccc
No known key found for this signature in database
GPG Key ID: C8FA8C18DFB4702B

@ -0,0 +1,45 @@
import json
from collections.abc import Generator
from typing import Any, Optional
import requests
from configs import dify_config
from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
from libs.apo_utils import APOUtils
class OriginxServiceMonitorTool(BuiltinTool):
def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Generator[ToolInvokeMessage, None, None]:
node_name = tool_parameters.get("node_name")
start_time = tool_parameters.get("startTime")
end_time = tool_parameters.get("endTime")
pid = tool_parameters.get("pid")
params = {
'metricName': 'Thread Polaris Metrics - 北极星指标(进程) - 节点上被监控的服务列表',
'params': {
"node_name": node_name,
**({'pid': pid} if pid else {})
},
'startTime': start_time,
'endTime': end_time,
'step': APOUtils.get_step(start_time, end_time),
}
resp = requests.post(dify_config.APO_BACKEND_URL + '/api/metric/query', json=params)
list = resp.json()['result']
list = json.dumps({
'type': 'metric',
'display': True,
'unit': list['unit'],
'data': {
"timeseries": list['timeseries']
}
})
yield self.create_text_message(list)

@ -0,0 +1,70 @@
identity:
name: originx_service_monitor
author: APO
label:
en_US: Thread Polaris Metrics Process All monitor
zh_Hans: 查询节点上被监控的服务列表
pt_BR: Thread Polaris Metrics Process All monitor
description:
human:
en_US: Thread Polaris Metrics Process All monitor
zh_Hans: 查询节点上被监控的服务列表
pt_BR: Thread Polaris Metrics Process All monitor
llm: 查询节点上被监控的服务列表
display:
type: metric
title: Thread Polaris Metrics - 北极星指标(进程) - 节点上被监控的服务列表
unit: ns
parameters:
- name: node_name
type: string
required: true
label:
en_US: node_name
zh_Hans: node_name
pt_BR: node_name
human_description:
en_US: Specified node name
zh_Hans: 指定的主机名称
pt_BR: Specified pod name
llm_description: Specified pod name
form: llm
- name: pid
type: string
required: false
label:
en_US: pid
zh_Hans: pid
pt_BR: pid
human_description:
en_US: Specified Process ID
zh_Hans: 指定的进程ID
pt_BR: Specified Process ID
llm_description: Specified Process ID
form: llm
- name: startTime
type: number
required: true
label:
en_US: startTime
zh_Hans: startTime
pt_BR: startTime
human_description:
en_US: Data query start time
zh_Hans: 开始时间 (微秒)
pt_BR: Data query start time
llm_description: Data query start time
form: llm
- name: endTime
type: number
required: true
label:
en_US: endTime
zh_Hans: endTime
pt_BR: endTime
human_description:
en_US: Data query end time
zh_Hans: 结束时间 (微秒)
pt_BR: Data query end time
llm_description: Data query start time
form: llm
Loading…
Cancel
Save