From 0244715a8a4d59195cce504885bf3d6c3cff3ffd Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Mon, 27 Apr 2026 18:50:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20LLM=E5=92=8C=E6=90=9C=E7=B4=A2=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E8=AE=B0=E5=BD=95=E7=BB=9F=E8=AE=A1=E5=88=B0?= =?UTF-8?q?backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/www/app.js b/www/app.js index cea10cb..38a7b40 100644 --- a/www/app.js +++ b/www/app.js @@ -3957,6 +3957,9 @@ async function streamGenerate(userMsgIndex) { syncConversationToBackend(currentConversation); renderMessages(); + // 记录统计到 backend + logStatsToBackend('llm_call', currentConversation.agentId || 'chat', 1); + // 自动总结标题:第一次对话和每隔5次对话 const totalMessages = currentConversation.messages.length; // 第一次对话(用户+AI=2条)或每5次对话(10条) @@ -3966,6 +3969,15 @@ async function streamGenerate(userMsgIndex) { } } +// 记录统计到 backend +function logStatsToBackend(type, key, value = 1) { + fetch('/api/admin/stats/log', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ type, key, value }) + }).catch(e => console.error('统计记录失败:', e)); +} + // 执行 Tavily 搜索 async function performSearch(query) { try { @@ -3988,6 +4000,10 @@ async function performSearch(query) { } const data = await response.json(); + + // 记录搜索统计 + logStatsToBackend('search_call', 'tavily', 1); + return data.results || []; } catch (error) { console.error('搜索错误:', error);