Skip to content

Commit 061c189

Browse files
committed
Update Mistral AI chat model enumeration
- Add Devstral Medium model - Add Ministral 14B model - Move Ministraux models to free models section - Follow the same naming convention for all models - Use latest version for Pixtral 12B model - Update models documentation link Signed-off-by: Nicolas Krier <7557886+nicolaskrier@users.noreply.github.com>
1 parent e065965 commit 061c189

File tree

16 files changed

+53
-49
lines changed

16 files changed

+53
-49
lines changed

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/main/java/org/springframework/ai/model/mistralai/autoconfigure/MistralAiChatProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class MistralAiChatProperties extends MistralAiParentProperties {
3535

3636
public static final String CONFIG_PREFIX = "spring.ai.mistralai.chat";
3737

38-
public static final String DEFAULT_CHAT_MODEL = MistralAiApi.ChatModel.SMALL.getValue();
38+
public static final String DEFAULT_CHAT_MODEL = MistralAiApi.ChatModel.MISTRAL_SMALL.getValue();
3939

4040
private static final Double DEFAULT_TOP_P = 1.0;
4141

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusBeanIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,8 @@ class PaymentStatusBeanIT {
6060
void functionCallTest() {
6161

6262
this.contextRunner
63-
.withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.LARGE.getValue())
63+
.withPropertyValues(
64+
"spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.MISTRAL_LARGE.getValue())
6465
.run(context -> {
6566

6667
MistralAiChatModel chatModel = context.getBean(MistralAiChatModel.class);

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusBeanOpenAiIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -68,7 +68,8 @@ class PaymentStatusBeanOpenAiIT {
6868
void functionCallTest() {
6969

7070
this.contextRunner
71-
.withPropertyValues("spring.ai.openai.chat.options.model=" + MistralAiApi.ChatModel.SMALL.getValue())
71+
.withPropertyValues(
72+
"spring.ai.openai.chat.options.model=" + MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
7273
.run(context -> {
7374

7475
OpenAiChatModel chatModel = context.getBean(OpenAiChatModel.class);

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/PaymentStatusPromptIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,7 +56,8 @@ public class PaymentStatusPromptIT {
5656
@Test
5757
void functionCallTest() {
5858
this.contextRunner
59-
.withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.SMALL.getValue())
59+
.withPropertyValues(
60+
"spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
6061
.run(context -> {
6162

6263
MistralAiChatModel chatModel = context.getBean(MistralAiChatModel.class);

auto-configurations/models/spring-ai-autoconfigure-model-mistral-ai/src/test/java/org/springframework/ai/model/mistralai/autoconfigure/tool/WeatherServicePromptIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,7 +62,8 @@ public class WeatherServicePromptIT {
6262
@Test
6363
void promptFunctionCall() {
6464
this.contextRunner
65-
.withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.LARGE.getValue())
65+
.withPropertyValues(
66+
"spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.MISTRAL_LARGE.getValue())
6667
.run(context -> {
6768

6869
MistralAiChatModel chatModel = context.getBean(MistralAiChatModel.class);
@@ -91,7 +92,8 @@ void promptFunctionCall() {
9192
@Test
9293
void functionCallWithPortableFunctionCallingOptions() {
9394
this.contextRunner
94-
.withPropertyValues("spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.LARGE.getValue())
95+
.withPropertyValues(
96+
"spring.ai.mistralai.chat.options.model=" + MistralAiApi.ChatModel.MISTRAL_LARGE.getValue())
9597
.run(context -> {
9698

9799
MistralAiChatModel chatModel = context.getBean(MistralAiChatModel.class);

models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiChatModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public static final class Builder {
570570
.temperature(0.7)
571571
.topP(1.0)
572572
.safePrompt(false)
573-
.model(MistralAiApi.ChatModel.SMALL.getValue())
573+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
574574
.build();
575575

576576
private ToolCallingManager toolCallingManager = DEFAULT_TOOL_CALLING_MANAGER;

models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/api/MistralAiApi.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ public enum ChatCompletionFinishReason {
248248
/**
249249
* List of well-known Mistral chat models.
250250
*
251-
* @see <a href=
252-
* "https://docs.mistral.ai/getting-started/models/models_overview/">Mistral AI Models
253-
* Overview</a>
251+
* @see <a href="https://docs.mistral.ai/getting-started/models">Mistral AI Models</a>
254252
*/
255253
public enum ChatModel implements ChatModelDescription {
256254

@@ -259,15 +257,17 @@ public enum ChatModel implements ChatModelDescription {
259257
MAGISTRAL_MEDIUM("magistral-medium-latest"),
260258
MISTRAL_MEDIUM("mistral-medium-latest"),
261259
CODESTRAL("codestral-latest"),
262-
LARGE("mistral-large-latest"),
260+
DEVSTRAL_MEDIUM("devstral-medium-latest"),
261+
MISTRAL_LARGE("mistral-large-latest"),
263262
PIXTRAL_LARGE("pixtral-large-latest"),
264-
MINISTRAL_3B_LATEST("ministral-3b-latest"),
265-
MINISTRAL_8B_LATEST("ministral-8b-latest"),
266263
// Free Models
264+
MINISTRAL_3B("ministral-3b-latest"),
265+
MINISTRAL_8B("ministral-8b-latest"),
266+
MINISTRAL_14B("ministral-14b-latest"),
267267
MAGISTRAL_SMALL("magistral-small-latest"),
268268
DEVSTRAL_SMALL("devstral-small-latest"),
269-
SMALL("mistral-small-latest"),
270-
PIXTRAL("pixtral-12b-2409"),
269+
MISTRAL_SMALL("mistral-small-latest"),
270+
PIXTRAL_12B("pixtral-12b-latest"),
271271
// Free Models - Research
272272
OPEN_MISTRAL_NEMO("open-mistral-nemo");
273273
// @formatter:on
@@ -292,9 +292,7 @@ public String getName() {
292292
/**
293293
* List of well-known Mistral embedding models.
294294
*
295-
* @see <a href=
296-
* "https://docs.mistral.ai/getting-started/models/models_overview/">Mistral AI Models
297-
* Overview</a>
295+
* @see <a href="https://docs.mistral.ai/getting-started/models">Mistral AI Models</a>
298296
*/
299297
public enum EmbeddingModel {
300298

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatClientIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -226,7 +226,7 @@ void functionCallTest() {
226226

227227
// @formatter:off
228228
String response = ChatClient.create(this.chatModel).prompt()
229-
.options(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.SMALL).toolChoice(ToolChoice.AUTO).build())
229+
.options(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.MISTRAL_SMALL).toolChoice(ToolChoice.AUTO).build())
230230
.user(u -> u.text("What's the weather like in San Francisco, Tokyo, and Paris? Use parallel function calling if required. Response should be in Celsius."))
231231
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
232232
.description("Get the weather in location")
@@ -248,7 +248,7 @@ void defaultFunctionCallTest() {
248248

249249
// @formatter:off
250250
String response = ChatClient.builder(this.chatModel)
251-
.defaultOptions(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.SMALL).build())
251+
.defaultOptions(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.MISTRAL_SMALL).build())
252252
.defaultToolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
253253
.description("Get the weather in location")
254254
.inputType(MockWeatherService.Request.class)
@@ -270,7 +270,7 @@ void streamFunctionCallTest() {
270270

271271
// @formatter:off
272272
Flux<String> response = ChatClient.create(this.chatModel).prompt()
273-
.options(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.SMALL).build())
273+
.options(MistralAiChatOptions.builder().model(MistralAiApi.ChatModel.MISTRAL_SMALL).build())
274274
.user("What's the weather like in San Francisco, Tokyo, and Paris? Use parallel function calling if required. Response should be in Celsius.")
275275
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
276276
.description("Get the weather in location")
@@ -291,7 +291,7 @@ void streamFunctionCallTest() {
291291
@Test
292292
void validateCallResponseMetadata() {
293293
// String model = MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getName();
294-
String model = MistralAiApi.ChatModel.PIXTRAL.getName();
294+
String model = MistralAiApi.ChatModel.PIXTRAL_12B.getName();
295295
// String model = MistralAiApi.ChatModel.PIXTRAL_LARGE.getName();
296296
// @formatter:off
297297
ChatResponse response = ChatClient.create(this.chatModel).prompt()

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatModelIT.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.ai.mistralai;
1818

19-
import java.io.IOException;
2019
import java.net.URI;
2120
import java.util.ArrayList;
2221
import java.util.Arrays;
@@ -224,7 +223,7 @@ void functionCallTest() {
224223
List<Message> messages = new ArrayList<>(List.of(userMessage));
225224

226225
var promptOptions = MistralAiChatOptions.builder()
227-
.model(MistralAiApi.ChatModel.SMALL.getValue())
226+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
228227
.toolCallbacks(List.of(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
229228
.description("Get the weather in location")
230229
.inputType(MockWeatherService.Request.class)
@@ -249,7 +248,7 @@ void streamFunctionCallTest() {
249248
List<Message> messages = new ArrayList<>(List.of(userMessage));
250249

251250
var promptOptions = MistralAiChatOptions.builder()
252-
.model(MistralAiApi.ChatModel.SMALL.getValue())
251+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
253252
.toolCallbacks(List.of(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
254253
.description("Get the weather in location")
255254
.inputType(MockWeatherService.Request.class)
@@ -291,7 +290,7 @@ void multiModalityEmbeddedImage(String modelName) {
291290

292291
@ParameterizedTest(name = "{0} : {displayName} ")
293292
@ValueSource(strings = { "pixtral-large-latest" })
294-
void multiModalityImageUrl(String modelName) throws IOException {
293+
void multiModalityImageUrl(String modelName) {
295294
var userMessage = UserMessage.builder()
296295
.text("Explain what do you see on this picture?")
297296
.media(List.of(Media.builder()
@@ -309,7 +308,7 @@ void multiModalityImageUrl(String modelName) throws IOException {
309308
}
310309

311310
@Test
312-
void streamingMultiModalityImageUrl() throws IOException {
311+
void streamingMultiModalityImageUrl() {
313312
var userMessage = UserMessage.builder()
314313
.text("Explain what do you see on this picture?")
315314
.media(List.of(Media.builder()
@@ -341,7 +340,7 @@ void streamFunctionCallUsageTest() {
341340
List<Message> messages = new ArrayList<>(List.of(userMessage));
342341

343342
var promptOptions = MistralAiChatOptions.builder()
344-
.model(MistralAiApi.ChatModel.SMALL.getValue())
343+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
345344
.toolCallbacks(List.of(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
346345
.description("Get the weather in location")
347346
.inputType(MockWeatherService.Request.class)

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiChatModelObservationIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void beforeEach() {
7070
@Test
7171
void observationForChatOperation() {
7272
var options = MistralAiChatOptions.builder()
73-
.model(MistralAiApi.ChatModel.SMALL.getValue())
73+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
7474
.maxTokens(2048)
7575
.stop(List.of("this-is-the-end"))
7676
.temperature(0.7)
@@ -94,7 +94,7 @@ void observationForChatOperation() {
9494
@Test
9595
void observationForStreamingChatOperation() {
9696
var options = MistralAiChatOptions.builder()
97-
.model(MistralAiApi.ChatModel.SMALL.getValue())
97+
.model(MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
9898
.maxTokens(2048)
9999
.stop(List.of("this-is-the-end"))
100100
.temperature(0.7)
@@ -131,12 +131,12 @@ private void validate(ChatResponseMetadata responseMetadata) {
131131
.doesNotHaveAnyRemainingCurrentObservation()
132132
.hasObservationWithNameEqualTo(DefaultChatModelObservationConvention.DEFAULT_NAME)
133133
.that()
134-
.hasContextualNameEqualTo("chat " + MistralAiApi.ChatModel.SMALL.getValue())
134+
.hasContextualNameEqualTo("chat " + MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
135135
.hasLowCardinalityKeyValue(LowCardinalityKeyNames.AI_OPERATION_TYPE.asString(),
136136
AiOperationType.CHAT.value())
137137
.hasLowCardinalityKeyValue(LowCardinalityKeyNames.AI_PROVIDER.asString(), AiProvider.MISTRAL_AI.value())
138138
.hasLowCardinalityKeyValue(LowCardinalityKeyNames.REQUEST_MODEL.asString(),
139-
MistralAiApi.ChatModel.SMALL.getValue())
139+
MistralAiApi.ChatModel.MISTRAL_SMALL.getValue())
140140
.hasLowCardinalityKeyValue(LowCardinalityKeyNames.RESPONSE_MODEL.asString(),
141141
StringUtils.hasText(responseMetadata.getModel()) ? responseMetadata.getModel()
142142
: KeyValue.NONE_VALUE)

0 commit comments

Comments
 (0)