Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,23 +282,14 @@ public enum ChatModel implements ChatModelDescription {

// @formatter:off
// Premier Models
@Deprecated(forRemoval = true) // Retirement planned the 31st of July 2026
MAGISTRAL_MEDIUM("magistral-medium-latest"),
CODESTRAL("codestral-latest"),
// Free Models
MINISTRAL_3B("ministral-3b-latest"),
MINISTRAL_8B("ministral-8b-latest"),
MINISTRAL_14B("ministral-14b-latest"),
MISTRAL_SMALL("mistral-small-latest"),
MISTRAL_MEDIUM("mistral-medium-latest"),
MISTRAL_LARGE("mistral-large-latest"),
@Deprecated(forRemoval = true) // Retirement planned the 31st of July 2026
DEVSTRAL("devstral-latest"),
@Deprecated(forRemoval = true) // Retirement planned the 31st of July 2026
MAGISTRAL_SMALL("magistral-small-latest"),
// Free Models - Research
@Deprecated(forRemoval = true) // Retirement planned the 31st of July 2026
OPEN_MISTRAL_NEMO("open-mistral-nemo");
Comment on lines -295 to -301

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these enums is breaking binary compatibility. Please, include a sub-section in upgrade-notes.adoc under the section [[upgrading-to-2-0-1]], describing the breakage of backward compatibility and what a user needs to do in order to successfully upgrade to 2.0.1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this comment. I forgot to add an upgrade note in a previous similar PR, although it is very useful for users. Please let me know what you think about the upgrade note I have just added.

I noticed that you assigned the 2.1.x milestone to this PR instead of 2.0.1. Could you tell me which version we are targeting? I will adapt the upgrade note version accordingly if necessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry about the confusion. It is not a practice in Spring to break binary compatibility in a patch release (like 2.0.1), thus we have to target 2.1.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanations. I have just created a new Upgrading to 2.1.0 section, please let me know what do you think about it.

MISTRAL_LARGE("mistral-large-latest");
// @formatter:on

private final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.springframework.ai.converter.ListOutputConverter;
import org.springframework.ai.converter.MapOutputConverter;
import org.springframework.ai.mistralai.api.MistralAiApi;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.ReasoningEffort;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.ResponseFormat;
import org.springframework.ai.model.tool.DefaultToolCallingManager;
import org.springframework.ai.model.tool.ToolCallingManager;
Expand Down Expand Up @@ -642,9 +643,10 @@ private static boolean hasMetadata(List<AssistantMessage> assistantMessages, Str
}

private static Prompt createThinkingPrompt(MistralAiApi.ChatModel chatModel) {
var reasoningEffort = ThinkingModelUtils.provideReasoningEffort(chatModel);
var model = ThinkingModelUtils.provideChatModelValue(chatModel);
var chatOptions = MistralAiChatOptions.builder().model(model).reasoningEffort(reasoningEffort).build();
var chatOptions = MistralAiChatOptions.builder()
.model(chatModel.getValue())
.reasoningEffort(ReasoningEffort.HIGH)
.build();
var systemMessage = new SystemMessage("You are a helpful assistant providing accurate short answers.");
var userMessage = new UserMessage(
"What is the first planet of the solar system based on the mass in descending order?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@EnumSource(value = ChatModel.class, names = { "MAGISTRAL_MEDIUM", "MISTRAL_MEDIUM", "MISTRAL_SMALL" })
@EnumSource(value = ChatModel.class, names = { "MISTRAL_MEDIUM", "MISTRAL_SMALL" })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dimitarproynov: The integration tests are currently failing for Mistral Medium on the main branch. Do you plan to create a maintenance branch for 2.0.x soon and to continue 2.1.x on main?

  • If so, we should consider merging this PR to main and applying changes from this PR regarding integration tests on 2.0.x branch.
  • If not, we should consider splitting this PR into parts:
    • one with just the integration test fixes, to merge to main ASAP,
    • one for removing Mistral AI chat model enumeration elements, to merge to main later on.

What do you think about it?

public @interface ThinkingModelSource {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import reactor.core.publisher.Flux;

import org.springframework.ai.mistralai.ThinkingModelSource;
import org.springframework.ai.mistralai.ThinkingModelUtils;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletion;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionChunk;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionMessage;
Expand All @@ -42,6 +41,7 @@
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionMessage.TextChunk;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionMessage.ToolCall;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.ReasoningEffort;
import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.ToolChoice;
import org.springframework.ai.mistralai.api.MistralAiApi.Embedding;
import org.springframework.ai.mistralai.api.MistralAiApi.EmbeddingList;
Expand Down Expand Up @@ -252,8 +252,8 @@ private static String extractReferencesAsJsonString() {
}

private static ChatCompletionRequest createChatCompletionRequest(MistralAiApi.ChatModel chatModel, boolean stream) {
var reasoningEffort = ThinkingModelUtils.provideReasoningEffort(chatModel);
var model = ThinkingModelUtils.provideChatModelValue(chatModel);
var reasoningEffort = ReasoningEffort.HIGH;
var model = chatModel.getValue();
var systemChatCompletionMessage = new ChatCompletionMessage(
List.of(new TextChunk("You are a helpful assistant providing accurate short answers.")), Role.SYSTEM);
var userChatCompletionMessage = new ChatCompletionMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ For more information about structured outputs, see the xref:api/structured-outpu
Mistral offers two approaches to reasoning:

* Adjustable: Available on Mistral Small 4 and Mistral Medium 3.5 via the `reasoning_effort` parameter. Enables the model to think to varying degrees.
* Native: Available for the Magistral model family. These models always generate reasoning traces and are purpose-built for deep reasoning tasks.
* Native: Available for the Magistral model family. These models always generate reasoning traces and are purpose-built for deep reasoning tasks. They have been deprecated and are no longer available.

=== Reasoning Effort

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
[[upgrade-notes]]
= Upgrade Notes

[[upgrading-to-2-1-0]]
== Upgrading to 2.1.0

=== Mistral AI Chat Models

The following deprecated Mistral AI chat models have been removed from the `MistralAiApi.ChatModel` enumeration, as they are no longer available (retired on the 31st of July 2026):

- `DEVSTRAL`,
- `MAGISTRAL_MEDIUM`,
- `MAGISTRAL_SMALL`,
- `OPEN_MISTRAL_NEMO`.

==== Impact

Using these models will now cause:

- **Compilation failure**: If referenced directly from `MistralAiApi.ChatModel`.
- **Potentially unintended behavior**: If used via the `spring.ai.mistralai.chat.model` property, as Mistral AI redirects requests to these deprecated models to alternative models (for instance, `magistral-medium-latest` is redirected to `mistral-medium-3.5`).

==== Migration

Replace these models with active alternatives. Refer to the https://docs.mistral.ai/models/overview#legacy-models[Mistral AI Legacy Models documentation] for recommended replacements.

You could consider switching to `MISTRAL_SMALL` or `MISTRAL_MEDIUM` with reasoning effort set to `MistralAiApi.ChatCompletionRequest.ReasoningEffort.HIGH` if you were using a Magistral model previously.

[[upgrading-to-2-0-1]]
== Upgrading to 2.0.1

Expand Down
Loading