From 192e070516beb5bd1e8aedd8e3002760ace76eb3 Mon Sep 17 00:00:00 2001 From: Metona Date: Sun, 5 Apr 2026 00:50:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20RAG=E7=8A=B6=E6=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=94=BEAI=E5=9B=9E=E5=A4=8D=E4=B8=8B=E6=96=B9=EF=BC=8C?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=9B=9E=E5=A4=8D=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E7=95=99=E5=8E=86=E5=8F=B2RAG=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - appendAssistantPlaceholder 回到 RAG 检索之前(placeholder在上方) - RAG 状态消息显示在 placeholder 下方 - 开始回复时清除临时状态消息 - 历史记录中通过 ragSources 展示知识库来源 --- js/components/input-area.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/components/input-area.js b/js/components/input-area.js index 18f016b..be530e3 100644 --- a/js/components/input-area.js +++ b/js/components/input-area.js @@ -370,6 +370,9 @@ export async function sendMessage() { filePreviewEl.innerHTML = ''; autoResizeTextarea(); + // 助手占位 + appendAssistantPlaceholder(); + // 流式回复 state.set(KEYS.IS_STREAMING, true); updateSendButton(true); @@ -465,8 +468,8 @@ ${ragContext} console.log('[RAG] numCtx:', numCtx, 'system长度:', chatParams.system?.length || 0); console.log('[RAG] 开始调用 chatStream...'); - // 助手占位(放在RAG检索之后,确保消息顺序:用户 → 检索状态 → AI) - appendAssistantPlaceholder(); + // 开始回复时清除 RAG 临时状态消息 + document.querySelectorAll('.rag-status').forEach(el => el.remove()); await api.chatStream(chatParams, (chunk) => { if (chunk.message) { @@ -510,6 +513,9 @@ ${ragContext} } catch (err) { console.error('[InputArea] 流式聊天错误:', err); + // 清除 RAG 临时状态消息 + document.querySelectorAll('.rag-status').forEach(el => el.remove()); + if (err.name === 'AbortError') { const placeholder = document.querySelector('#messagesContainer .message.assistant.loading'); const loadingDots = placeholder?.querySelector('.loading-dots');