fix: RAG状态消息放AI回复下方,开始回复时清除,保留历史RAG来源展示
- appendAssistantPlaceholder 回到 RAG 检索之前(placeholder在上方) - RAG 状态消息显示在 placeholder 下方 - 开始回复时清除临时状态消息 - 历史记录中通过 ragSources 展示知识库来源
This commit is contained in:
@@ -370,6 +370,9 @@ export async function sendMessage() {
|
|||||||
filePreviewEl.innerHTML = '';
|
filePreviewEl.innerHTML = '';
|
||||||
autoResizeTextarea();
|
autoResizeTextarea();
|
||||||
|
|
||||||
|
// 助手占位
|
||||||
|
appendAssistantPlaceholder();
|
||||||
|
|
||||||
// 流式回复
|
// 流式回复
|
||||||
state.set(KEYS.IS_STREAMING, true);
|
state.set(KEYS.IS_STREAMING, true);
|
||||||
updateSendButton(true);
|
updateSendButton(true);
|
||||||
@@ -465,8 +468,8 @@ ${ragContext}
|
|||||||
console.log('[RAG] numCtx:', numCtx, 'system长度:', chatParams.system?.length || 0);
|
console.log('[RAG] numCtx:', numCtx, 'system长度:', chatParams.system?.length || 0);
|
||||||
console.log('[RAG] 开始调用 chatStream...');
|
console.log('[RAG] 开始调用 chatStream...');
|
||||||
|
|
||||||
// 助手占位(放在RAG检索之后,确保消息顺序:用户 → 检索状态 → AI)
|
// 开始回复时清除 RAG 临时状态消息
|
||||||
appendAssistantPlaceholder();
|
document.querySelectorAll('.rag-status').forEach(el => el.remove());
|
||||||
|
|
||||||
await api.chatStream(chatParams, (chunk) => {
|
await api.chatStream(chatParams, (chunk) => {
|
||||||
if (chunk.message) {
|
if (chunk.message) {
|
||||||
@@ -510,6 +513,9 @@ ${ragContext}
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[InputArea] 流式聊天错误:', err);
|
console.error('[InputArea] 流式聊天错误:', err);
|
||||||
|
|
||||||
|
// 清除 RAG 临时状态消息
|
||||||
|
document.querySelectorAll('.rag-status').forEach(el => el.remove());
|
||||||
|
|
||||||
if (err.name === 'AbortError') {
|
if (err.name === 'AbortError') {
|
||||||
const placeholder = document.querySelector('#messagesContainer .message.assistant.loading');
|
const placeholder = document.querySelector('#messagesContainer .message.assistant.loading');
|
||||||
const loadingDots = placeholder?.querySelector('.loading-dots');
|
const loadingDots = placeholder?.querySelector('.loading-dots');
|
||||||
|
|||||||
Reference in New Issue
Block a user