feat: use StreamingChunk.reasoning field in Ollama chat generator#2850
Open
yaowubarbara wants to merge 1 commit intodeepset-ai:mainfrom
Open
feat: use StreamingChunk.reasoning field in Ollama chat generator#2850yaowubarbara wants to merge 1 commit intodeepset-ai:mainfrom
yaowubarbara wants to merge 1 commit intodeepset-ai:mainfrom
Conversation
Populate the dedicated StreamingChunk.reasoning field with ReasoningContent instead of storing thinking data in meta dict. Update accumulation logic and tests accordingly. Closes deepset-ai/haystack#10481
4 tasks
Contributor
|
Once all comments on #2849 are resolved let's make sure to bring all learnings to this PR as well. |
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 mirrors the approach from #2849 (Anthropic) for the Ollama integration:
StreamingChunk.reasoningwithReasoningContentinstead of stuffing thinking data intometa["reasoning"]chunk.reasoningThe Ollama case is simpler than Anthropic since there are no signatures or redacted thinking blocks — just a plain
message.thinkingstring per chunk.Changes
_build_chunk(): createReasoningContentfrom thethinkingfield and pass it as thereasoningkwarg_handle_streaming_response()/_handle_streaming_response_async(): readc.reasoning.reasoning_textinstead ofc.meta.get("reasoning")chunk.reasoning.reasoning_textinstead ofchunk.meta["reasoning"]Related: deepset-ai/haystack#10481
Related: deepset-ai/haystack#9785 (parent tracking issue)