Fix(components): conversational retrieval qa streaming regression#6089
Open
estebanjosse wants to merge 9 commits intoFlowiseAI:mainfrom
Open
Fix(components): conversational retrieval qa streaming regression#6089estebanjosse wants to merge 9 commits intoFlowiseAI:mainfrom
estebanjosse wants to merge 9 commits intoFlowiseAI:mainfrom
Conversation
…sert source-doc streaming
Contributor
Author
|
Closes #6070 |
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the ConversationalRetrievalQAChain to use answerChain.invoke instead of streamLog, implementing a CustomChainHandler for streaming and restructuring the internal chain to better handle source documents. A new test suite is also introduced to verify streaming and document retrieval. The reviewer identified a redundant call to serializeHistory when checking for chat history, suggesting a more efficient check using the history array's length.
...ges/components/nodes/chains/ConversationalRetrievalQAChain/ConversationalRetrievalQAChain.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a streaming regression in the Conversational Retrieval QA Chain introduced in 3.1.x, where responses were no longer streamed token-by-token and were instead returned only once completed.
In addition to restoring streaming, this PR refactors the streaming implementation to make it more maintainable, consistent with other chains, and significantly easier to test.
Root cause
The previous implementation relied on a manual JSON patch-based streaming mechanism using
streamLog()andapplyPatchto reconstruct streamed output.This approach:
Fix
This PR replaces the JSON patch-based streaming logic with a callback handler-based approach using
CustomChainHandler, aligning the implementation withConversationChain.Key changes:
streamLog()/ JSON patch parsing (applyPatch)CustomChainHandlerThis results in:
Refactoring
RunnableSequenceandRunnableMapfor better clarity and modularityTests
ConversationalRetrievalQAChain.test.ts)Behavioral improvements
ConversationalRetrievalQAResultImpact
Notes
This change removes reliance on
streamLog()for streaming and aligns the implementation with the callback-based pattern already used in other parts of the codebase.