Conversation
…enAIChatGenerator so we can overwrite it in integrations that inherit from it
|
@anakin87 I'm setting @julian-risch as the reviewer since he reviewed the original PR that introduced the new fields to StreamingChunk so he has the most context for these changes. |
|
Sorry @julian-risch and @anakin87 I'm switching this to draft for now. I've run into some challenges with Mistral so I'm considering rethinking how StreamingChunk works with respect to handling multiple tool calls. |
Pull Request Test Coverage Report for Build 15818567920Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
_convert_chat_completion_chunk_to_streaming_chunk a member function of OpenAIChatGenerator and small fixes to setting StreamingChunk.indexStreamingChunk, better index setting and change tool_call to tool_calls
…om:deepset-ai/haystack into update-to-chat-completion-chunk-conversion
julian-risch
left a comment
There was a problem hiding this comment.
Looks good to me! 👍 I didn't find anything that needs to be changed. For the three consecutive print lines, I suggest to combine them but I don't want to block the PR because of that simplification.
Related Issues
_convert_chat_completion_chunk_to_streaming_chunkworks as expected for integrations that inheritOpenAIChatGenerator#9502Proposed Changes:
_convert_chat_completion_chunk_to_streaming_chunkto properly setindex=Nonein the case for streaming chunks that only contain role information or have their content set to None (e.g. when providingfinish_reason). This was the original intent ofStreamingChunk.index, but was missed in the original PR.tool_callsfield instead of a singulartool_call. Sotool_callsbecomesOptional[List[ToolCallDelta]]to better reflect that a OpenAI Chunk can have multiple tool calls in it. I was able to test this behavior for the first time when using the MistralChatGenerator.print_streaming_callbackfunction to accommodate this changeHow did you test it?
Notes for the reviewer
Example of OpenAI Agent Streaming Formatting

Example of Mistral Agent Streaming Formatting

Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.