From feabfc853771afa603971aeab050b32a850dbac4 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Tue, 21 Apr 2026 11:55:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9chat=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src/api/index.js | 16 +- dashboard/src/views/AgentsView.vue | 216 +++++++++- dashboard/vite.config.js | 9 +- luxx/agents/base.py | 203 ++-------- luxx/api/agents.py | 4 +- luxx/services/__init__.py | 18 +- luxx/services/agent.py | 9 +- luxx/services/chat.py | 630 ++++++----------------------- luxx/services/interfaces.py | 68 ++++ luxx/services/llm_client.py | 56 +-- luxx/services/llm_service.py | 113 ++++++ luxx/services/message_service.py | 158 ++++++++ luxx/services/room.py | 64 ++- luxx/services/stream_service.py | 472 +++++++++++++++++++++ 14 files changed, 1321 insertions(+), 715 deletions(-) create mode 100644 luxx/services/interfaces.py create mode 100644 luxx/services/llm_service.py create mode 100644 luxx/services/message_service.py create mode 100644 luxx/services/stream_service.py diff --git a/dashboard/src/api/index.js b/dashboard/src/api/index.js index 69241cd..15f3a2e 100644 --- a/dashboard/src/api/index.js +++ b/dashboard/src/api/index.js @@ -283,10 +283,22 @@ export function createRoomWS(roomId, callbacks = {}) { } }, sendMessage: (content, userId = 'user', userName = 'User') => { - ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + const send = () => { + if (ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + } else if (ws.readyState === WebSocket.CONNECTING) { + // Wait for connection then retry + ws.addEventListener('open', () => { + ws.send(JSON.stringify({ action: 'send_message', content, user_id: userId, user_name: userName })) + }, { once: true }) + } + } + send() }, ping: () => { - ws.send(JSON.stringify({ action: 'ping' })) + if (ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify({ action: 'ping' })) + } }, close: () => ws.close() } diff --git a/dashboard/src/views/AgentsView.vue b/dashboard/src/views/AgentsView.vue index 8e588ed..7279c37 100644 --- a/dashboard/src/views/AgentsView.vue +++ b/dashboard/src/views/AgentsView.vue @@ -33,6 +33,14 @@ +
+ + Provider: {{ getProviderName(agent.provider_id) }} + + 模型: {{ agent.model }} + 工具: {{ agent.tools.length }}个 +
+

{{ agent.system_prompt?.slice(0, 100) }}...

@@ -64,6 +72,47 @@ placeholder="定义 Agent 的行为和职责...">
+
+
+ + +
+
+ + +
+
+ + +
+
+ {{ selectedProvider.provider_type }} + + 默认模型: {{ selectedProvider.default_model }} + + + API: {{ selectedProvider.base_url }} + +
+
+ +
+ +
+ +
+
+
@@ -103,10 +152,12 @@