feat: Add full logs tool. (#16)

pull/18563/head
MisluNotFound 1 year ago committed by GitHub
parent a7870eee62
commit 9f798d2778
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -30,7 +30,7 @@ class FaultLogTool(BuiltinTool):
'pageSize': 10,
'pod': pod,
}
url = dify_config.APO_BACKEND_URL + "/api/log/fault/pagelist"
url = dify_config.APO_BACKEND_URL + "/api/log/fault/pagelist"
resp = requests.post(url, json=params)
log_list = resp.json().get('list', [])
list = []

@ -0,0 +1,47 @@
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
class QueryFullLogsTool(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]:
start_time = tool_parameters.get("startTime")
end_time = tool_parameters.get("endTime")
query = tool_parameters.get("query")
params = {
"dataBase": "apo",
"endTime": end_time,
"isExternal": False,
"pageNum" : 1,
"pageSize" : 100,
"query" : query,
"startTime" : start_time,
"tableName" : "raw_logs",
}
url = dify_config.APO_BACKEND_URL + "/api/log/query"
resp = requests.post(
url=url,
json=params,
)
list = json.dumps({
'type': 'log',
'display': True,
'data': resp.json(),
})
yield self.create_text_message(list)

@ -0,0 +1,51 @@
identity:
name: 查询全量日志
author: APO
label:
en_US: Query all logs.
zh_Hans: 查询全量日志
description:
human:
en_US: Query all logs.
zh_Hans: 查询全量日志
llm: Query all logs.
display:
type: log
title: log
unit: log
parameters:
- name: query
type: string
required: false
label:
en_US: Query condition(clickhouse where clause).
zh_Hans: 查询条件clickhouse where子句
human_description:
en_US: Query condition(clickhouse where clause).
zh_Hans: 查询条件clickhouse where子句
llm_description: Query condition(clickhouse where clause).
form: llm
- name: startTime
type: number
required: true
label:
en_US: Start Time
zh_Hans: 开始时间
human_description:
en_US: Start timestamp in microseconds
zh_Hans: 查询开始时间(微秒)
llm_description: Microsecond timestamp for start time
form: llm
- name: endTime
type: number
required: true
label:
en_US: End Time
zh_Hans: 结束时间
human_description:
en_US: End timestamp in microseconds
zh_Hans: 查询结束时间(微秒)
llm_description: Microsecond timestamp for end time
form: llm
Loading…
Cancel
Save