From a8aa00ce051f96b21b00b7d7b8c2670a9671011b Mon Sep 17 00:00:00 2001 From: Metona Date: Sun, 5 Apr 2026 00:46:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20RAG=E6=A3=80=E7=B4=A2=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BF=9D=E7=95=99=E5=9C=A8AI=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E4=B8=8A=E6=96=B9=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=9B=9E=E9=A1=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 appendAssistantPlaceholder() 移到 RAG 检索之后 - 消息顺序:用户消息 → 检索状态 → AI回复 - 移除 rag-status 清除逻辑,检索状态永久保留 --- js/components/input-area.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/js/components/input-area.js b/js/components/input-area.js index 39e0519..18f016b 100644 --- a/js/components/input-area.js +++ b/js/components/input-area.js @@ -370,9 +370,6 @@ export async function sendMessage() { filePreviewEl.innerHTML = ''; autoResizeTextarea(); - // 助手占位 - appendAssistantPlaceholder(); - // 流式回复 state.set(KEYS.IS_STREAMING, true); updateSendButton(true); @@ -468,6 +465,9 @@ ${ragContext} console.log('[RAG] numCtx:', numCtx, 'system长度:', chatParams.system?.length || 0); console.log('[RAG] 开始调用 chatStream...'); + // 助手占位(放在RAG检索之后,确保消息顺序:用户 → 检索状态 → AI) + appendAssistantPlaceholder(); + await api.chatStream(chatParams, (chunk) => { if (chunk.message) { if (chunk.message.content) { @@ -485,9 +485,6 @@ ${ragContext} } }, abortController); - // 清除 RAG 临时状态消息 - document.querySelectorAll('.rag-status').forEach(el => el.remove()); - // 如果流结束但没有任何内容 if (!assistantContent && !thinkContent) { appendSystemMessage('⚠️ 模型未返回任何内容,可能是上下文过长或模型不支持当前请求'); @@ -513,9 +510,6 @@ ${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');