fix: RAG临时状态消息延迟到首个token到达时才清除,消除回复前的空白期
This commit is contained in:
@@ -477,10 +477,14 @@ ${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 临时状态消息
|
let ragStatusCleared = false;
|
||||||
document.querySelectorAll('.rag-status').forEach(el => el.remove());
|
|
||||||
|
|
||||||
await api.chatStream(chatParams, (chunk) => {
|
await api.chatStream(chatParams, (chunk) => {
|
||||||
|
// 首个有效内容到达时才清除 RAG 状态,避免检索完到开始回复之间的空白
|
||||||
|
if (!ragStatusCleared && chunk.message?.content) {
|
||||||
|
ragStatusCleared = true;
|
||||||
|
document.querySelectorAll('.rag-status').forEach(el => el.remove());
|
||||||
|
}
|
||||||
if (chunk.message) {
|
if (chunk.message) {
|
||||||
if (chunk.message.content) {
|
if (chunk.message.content) {
|
||||||
assistantContent += chunk.message.content;
|
assistantContent += chunk.message.content;
|
||||||
|
|||||||
Reference in New Issue
Block a user