Improve MistralAiApi Jackson mapping for message content#5585
Draft
nicolaskrier wants to merge 1 commit intospring-projects:mainfrom
Draft
Improve MistralAiApi Jackson mapping for message content#5585nicolaskrier wants to merge 1 commit intospring-projects:mainfrom
nicolaskrier wants to merge 1 commit intospring-projects:mainfrom
Conversation
c8aa779 to
220088c
Compare
6563ab1 to
830333d
Compare
nicolaskrier
commented
Mar 20, 2026
| // "message":"A valid Content-Length header is required", | ||
| // "request_id":"5108031f4a1e0d3e6d66204d56b2ac60" | ||
| // } | ||
| // TODO: Discuss with Sébastien Deleuze the opportunity to add this class into Spring Framework if this solution is satisfying. |
Contributor
Author
There was a problem hiding this comment.
Hi @sdeleuze, could you have a look at this error and my corresponding fix proposal? Please note that this error is also affecting Spring AI 1.1.2. I have checked with my Spring AI Examples project that used to work well for all examples, except for the chat client example with Mistral AI, and now even the simplest example with Mistral AI API is broken due to this error.
Contributor
Author
There was a problem hiding this comment.
Just a heads up: this error has been reported on Mistral AI Discord, so let's wait for their response.
Contributor
Author
There was a problem hiding this comment.
Hum, the error doesn't occur anymore so I have removed the class.
c5c1c6c to
9a30eae
Compare
7bf07e6 to
7ad3557
Compare
- Define different type of chunk instead of media content - Introduce think chunk required by Magistral models and Mistral Small 4 - Introduce prompt_mode request parameter for Magistral models - Introduce reasoning_effort request parameter for Mistral Small 4 - Improve existing Javadoc - Polish integration tests and unit tests Signed-off-by: Nicolas Krier <7557886+nicolaskrier@users.noreply.github.com>
7ad3557 to
dc19db5
Compare
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.
Description
prompt_moderequest parameter for Magistral models,reasoning_effortrequest parameter for Mistral Small 4,Explanations
This PR aligns the Jackson mapping with the content types defined in the Mistral AI OpenAPI Specifications. The changes ensure null safety matches the OpenAPI Specifications requirements and introduce support for new content types used by Magistral 1.2 models. New Mistral Small 4 model reasoning on demand feature is also added in order to cover all Mistral reasoning models at
MistralAiApilevel.Targeted milestone
2.0.0-M4
Related work
spring-ai-mistral-ainull-safe #5354,Remaining tasks
MistralAiApi.ChatCompletionMessageunit tests demonstratingcontentattribute serialization and deserialization,MistralAiApi.ChatCompletionMessage.ContentSerializerunit tests,MistralAiApi.ChatCompletionMessage.ContentDeserializerunit tests,MistralAiApi.ChatCompletionMessage.extractContentunit tests,MistralAiApi.ChatCompletionMessage.extractThinkingContentunit tests,MistralAiApiprompt_modeparameter support indicating reasoning for Magistral models,MistralAiApireasoning_effortparameter support for Mistral Small 4,MistralAiApiintegration tests demonstrating Mistral Small 4 reasoning on demand feature,MistralAiApiintegration test includingMistralAiApi.ChatCompletionMessage.ImageUrlChunk,MistralAiApiintegration test includingMistralAiApi.ChatCompletionMessage.ReferenceChunk.