From a4fdc0455a74377e1326ae079bb538dcdede8490 Mon Sep 17 00:00:00 2001 From: yzy_dev Date: Wed, 18 Dec 2024 18:40:21 +0800 Subject: [PATCH] Add agent toolsinfo and function tools --- llmops/config/config.py | 1 + llmops/llm-ops.yaml.template | 10 +++- .../llm_tools/function_call/tools/os_tools.py | 60 +++++++++++++++++++ .../function_call/tools/rpm_tools.py | 8 +++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 llmops/llm_tools/function_call/tools/os_tools.py create mode 100644 llmops/llm_tools/function_call/tools/rpm_tools.py diff --git a/llmops/config/config.py b/llmops/config/config.py index 7b586fdd..1211009a 100644 --- a/llmops/config/config.py +++ b/llmops/config/config.py @@ -13,6 +13,7 @@ class AppConf: server: str port: str debug: bool + tool_baseurl: str @dataclass class LlmConf: diff --git a/llmops/llm-ops.yaml.template b/llmops/llm-ops.yaml.template index 4dc7944d..450033f3 100644 --- a/llmops/llm-ops.yaml.template +++ b/llmops/llm-ops.yaml.template @@ -1,4 +1,12 @@ app: server: localhost port: 5000 - debug: true \ No newline at end of file + debug: + tool_baseurl: + + +llm: + model: +# apikey: + baseurl: + current_model: \ No newline at end of file diff --git a/llmops/llm_tools/function_call/tools/os_tools.py b/llmops/llm_tools/function_call/tools/os_tools.py new file mode 100644 index 00000000..584d18fb --- /dev/null +++ b/llmops/llm_tools/function_call/tools/os_tools.py @@ -0,0 +1,60 @@ +import requests + +from llmops.config.config import init_config + + +class OsFunctionTools: + config = init_config() + BASE_URL = config.app_conf.tool_baseurl + + @staticmethod + def get_agent_overview(UUID:str): + # 定义目标URL + print("OsFunctionTools be called!") + url = f"{OsFunctionTools.BASE_URL}/api/v1/api/agent_overview" + + # 如果需要传递查询参数,可以使用params参数 + params = { + "uuid": UUID + } + + # 发送GET请求 + response = requests.get(url, params=params) + + # 检查响应状态码 + if response.status_code == 200: + # 解析JSON响应 + data = response.json() + # print("Memory Info:", data) + return data + else: + print(f"Failed to get memory info. Status code: {response.status_code}") + return None + + +tools = { + "GetFullSystemData": { + "tool_name":"getAgentOverview", + "desc": "获取指定UUID客户端节点的全部系统信息,包括:" + "1.ip地址,是当前节点的ip地址" + "2.department:组织名,当前客户端节点所属的组织" + "3.state:当前节点的状态,是否在线" + "4.platform:平台类型" + "5.platform_version:平台版本" + "6.kernel_arch:内核" + "7.kernel_version:内核版本" + "8.cpu_num:cpu数量" + "9.model_name:cpu的硬件信息" + "10.memory_total:剩余内存memory空间" + "11.dis_usage:硬盘使用情况", + "args": { + "UUID": ( + "str", + "[*Required] Timezone string used in pytz.timezone() in Python" + ) + }, + "func": OsFunctionTools.get_agent_overview + }, + +} + diff --git a/llmops/llm_tools/function_call/tools/rpm_tools.py b/llmops/llm_tools/function_call/tools/rpm_tools.py new file mode 100644 index 00000000..e9e9521f --- /dev/null +++ b/llmops/llm_tools/function_call/tools/rpm_tools.py @@ -0,0 +1,8 @@ +from llmops.config.config import init_config + + +class RpmFunctionTools: + config = init_config() + BASE_URL = config.app_conf.tool_baseurl + + -- Gitee