From ba5d49005bfe18658c7bca07da66bc4595e3717c Mon Sep 17 00:00:00 2001
From: hubian <908234780@qq.com>
Date: Mon, 27 Apr 2026 23:44:37 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A?=
=?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=8C=89=E9=92=AE=EF=BC=8C=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E5=A4=9A=E9=80=89=E5=B7=A5=E5=85=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app.py | 5 ++
www/app.js | 163 ++++++++++++++++++++++++++++++++++++++++++
www/style.css | 187 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 355 insertions(+)
diff --git a/backend/app.py b/backend/app.py
index c6af9ca..08bf12f 100644
--- a/backend/app.py
+++ b/backend/app.py
@@ -1332,6 +1332,10 @@ def get_frontend_config():
cursor.execute('SELECT * FROM tool_configs WHERE is_default=1 AND is_active=1')
tools = [dict(row) for row in cursor.fetchall()]
+ # 获取所有活跃的工具配置(供前端选择)
+ cursor.execute('SELECT tool_id, name, type, provider, is_active FROM tool_configs WHERE is_active=1')
+ allTools = [dict(row) for row in cursor.fetchall()]
+
# 获取所有智能体(上线且活跃)
cursor.execute('SELECT agent_id, name, avatar, category, description, system_prompt, heat, tags, enable_tools FROM agents WHERE is_online=1 AND is_active=1')
agents = [dict(row) for row in cursor.fetchall()]
@@ -1349,6 +1353,7 @@ def get_frontend_config():
config = {
'llm': dict(llm) if llm else None,
'tools': tools,
+ 'allTools': allTools, # 所有活跃的工具(供前端选择)
'agents': agents,
'chat_config': dict(chat_config) if chat_config else None,
'system': {
diff --git a/www/app.js b/www/app.js
index 6b7cce0..16b1e50 100644
--- a/www/app.js
+++ b/www/app.js
@@ -116,6 +116,16 @@ async function loadBackendConfig() {
};
}
+ // 加载工具列表
+ if (backendConfig.allTools) {
+ allTools = backendConfig.allTools;
+ }
+
+ // 加载默认启用的工具
+ if (backendConfig.tools) {
+ enabledTools = backendConfig.tools.map(t => t.tool_id);
+ }
+
updateAgentsDisplay();
console.log('后台配置已加载', backendConfig);
} catch (e) {
@@ -282,6 +292,8 @@ function getAgentConversationHistory(limit = 5) {
let enableThinking = false; // 深度思考
let enableSearch = false; // 联网搜索
let autoScrollEnabled = true; // 自动滚动(用户滚动后可关闭)
+let enabledTools = []; // 启用的工具列表(多选)
+let allTools = []; // 所有可用的工具列表
// DOM 元素(初始为 null,在 openConversation 时重新获取)
let appContainer = null;
@@ -3129,6 +3141,11 @@ function showAgentChatPage() {
联网搜索
+
+