Repository navigation
Migrate Mistral AI chat model to message parts - #7145
Open
dimitarproynov wants to merge 1 commit into
Open
dimitarproynov wants to merge 1 commit into
dimitarproynov wants to merge 1 commit into
Conversation
MistralAiChatModel now builds the assistant message of each choice from ordered message parts. Mistral returns the content as an ordered list of chunks: a thinking chunk becomes a ReasoningPart with the mistral_ai provider attribute and its signature, if any, as an opaque payload; a text chunk becomes a TextPart; and a reference or image chunk becomes an UnknownPart holding the chunk as JSON. The tool calls, which Mistral returns in a separate field, follow as ToolCallParts. Streamed parts are stamped with their index per choice, so the MessageAggregator merges each run of deltas into one part. An assistant message is replayed as content chunks in part order. Mistral recommends sending the thinking of its reasoning models back, so a Mistral ReasoningPart goes back as a thinking chunk with its signature, while reasoning from another provider is not sent. A message without reasoning parts, such as one built by an earlier version, falls back to the thinking_content metadata, as OpenAiChatModel does with its reasoning metadata. User message parts are sent in order, so text and images can interleave. MistralAiApi.ThinkChunk gains the signature field of the API, with a constructor that keeps the previous components. getText() now joins the text chunks without the line separator, which split the text around a citation. Streamed chunks always carry the response id, and THINKING_CONTENT_METADATA is deprecated in favor of getReasoning(). Update the Mistral AI reference documentation and the upgrade notes. Signed-off-by: Dimitar Proynov <dimitar.proynov@broadcom.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.
MistralAiChatModel now builds the assistant message of each choice from ordered message parts. Mistral returns the content as an ordered list of chunks: a thinking chunk becomes a ReasoningPart with the mistral_ai provider attribute and its signature, if any, as an opaque payload; a text chunk becomes a TextPart; and a reference or image chunk becomes an UnknownPart holding the chunk as JSON. The tool calls, which Mistral returns in a separate field, follow as ToolCallParts. Streamed parts are stamped with their index per choice, so the MessageAggregator merges each run of deltas into one part.
An assistant message is replayed as content chunks in part order. Mistral recommends sending the thinking of its reasoning models back, so a Mistral ReasoningPart goes back as a thinking chunk with its signature, while reasoning from another provider is not sent. A message without reasoning parts, such as one built by an earlier version, falls back to the thinking_content metadata, as OpenAiChatModel does with its reasoning metadata. User message parts are sent in order, so text and images can interleave.
MistralAiApi.ThinkChunk gains the signature field of the API, with a constructor that keeps the previous components. getText() now joins the text chunks without the line separator, which split the text around a citation. Streamed chunks always carry the response id, and THINKING_CONTENT_METADATA is deprecated in favor of getReasoning().
Update the Mistral AI reference documentation and the upgrade notes.
Build, unit and integration tests pass.