mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-25 09:53:29 +08:00
Fix stale references shown while streaming and empty final reply in Go mode (#17146)
This commit is contained in:
@@ -40,9 +40,20 @@ export const buildMessageItemReference = (
|
||||
const referenceIndex = assistantMessages.findIndex(
|
||||
(x) => x.id === message.id,
|
||||
);
|
||||
// An assistant message that has not received any content yet is still
|
||||
// being generated. Never resolve its reference from the conversation
|
||||
// reference list — the indices only align with completed answers, so the
|
||||
// lookup would surface a stale reference from a previous turn (or from a
|
||||
// previously opened conversation) while the answer is streaming.
|
||||
const isPendingAnswer =
|
||||
message.role === MessageType.Assistant &&
|
||||
!message.content &&
|
||||
isEmpty(message?.reference);
|
||||
const reference = !isEmpty(message?.reference)
|
||||
? message?.reference
|
||||
: (conversation?.reference ?? [])[referenceIndex];
|
||||
: isPendingAnswer
|
||||
? undefined
|
||||
: (conversation?.reference ?? [])[referenceIndex];
|
||||
|
||||
return reference ?? { doc_aggs: [], chunks: [], total: 0 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user