fix: RAG检索状态消息保留在AI回复上方,方便历史回顾
- 将 appendAssistantPlaceholder() 移到 RAG 检索之后 - 消息顺序:用户消息 → 检索状态 → AI回复 - 移除 rag-status 清除逻辑,检索状态永久保留
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user