Skip to content

Commit 76072d2

Browse files
committed
Add Mistral AI Saba model
* Add Mistral Saba Latest model to ChatModel * Improve javadoc and update documentation links * Add small code enhancements Signed-off-by: Nicolas KRIER <[email protected]>
1 parent 29002df commit 76072d2

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public <T> ResponseEntity<EmbeddingList<Embedding>> embeddings(EmbeddingRequest<
139139

140140
// The input must not an empty string, and any array must be 1024 dimensions or
141141
// less.
142-
if (embeddingRequest.input() instanceof List list) {
142+
if (embeddingRequest.input() instanceof List<?> list) {
143143
Assert.isTrue(!CollectionUtils.isEmpty(list), "The input list can not be empty.");
144144
Assert.isTrue(list.size() <= 1024, "The list must be 1024 dimensions or less");
145145
Assert.isTrue(
@@ -255,12 +255,10 @@ public enum ChatCompletionFinishReason {
255255

256256
/**
257257
* List of well-known Mistral chat models.
258-
* https://docs.mistral.ai/platform/endpoints/#mistral-ai-generative-models
259258
*
260-
* <p>
261-
* Mistral AI provides two types of models: open-weights models (Mistral 7B, Mixtral
262-
* 8x7B, Mixtral 8x22B) and optimized commercial models (Mistral Small, Mistral
263-
* Medium, Mistral Large, and Mistral Embeddings).
259+
* @see <a href=
260+
* "https://docs.mistral.ai/getting-started/models/models_overview/">Mistral AI Models
261+
* Overview</a>
264262
*/
265263
public enum ChatModel implements ChatModelDescription {
266264

@@ -269,6 +267,7 @@ public enum ChatModel implements ChatModelDescription {
269267
CODESTRAL("codestral-latest"),
270268
LARGE("mistral-large-latest"),
271269
PIXTRAL_LARGE("pixtral-large-latest"),
270+
SABA_LATEST("mistral-saba-latest"),
272271
MINISTRAL_3B_LATEST("ministral-3b-latest"),
273272
MINISTRAL_8B_LATEST("ministral-8b-latest"),
274273
// Free Models
@@ -298,11 +297,15 @@ public String getName() {
298297

299298
/**
300299
* List of well-known Mistral embedding models.
301-
* https://docs.mistral.ai/platform/endpoints/#mistral-ai-embedding-model
300+
*
301+
* @see <a href=
302+
* "https://docs.mistral.ai/getting-started/models/models_overview/">Mistral AI Models
303+
* Overview</a>
302304
*/
303305
public enum EmbeddingModel {
304306

305307
// @formatter:off
308+
// Premier Models
306309
EMBED("mistral-embed");
307310
// @formatter:on
308311

@@ -799,8 +802,7 @@ public String content() {
799802
}
800803

801804
/**
802-
* The role of the author of this message.
803-
*
805+
* The role of the author of this message. <br/>
804806
* NOTE: Mistral expects the system message to be before the user message or will
805807
* fail with 400 error.
806808
*/

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* @since 0.8.1
4040
*/
4141
@EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+")
42-
public class MistralAiApiIT {
42+
class MistralAiApiIT {
4343

4444
MistralAiApi mistralAiApi = new MistralAiApi(System.getenv("MISTRAL_AI_API_KEY"));
4545

@@ -61,7 +61,7 @@ void chatCompletionEntityWithSystemMessage() {
6161
You are an AI assistant that helps people find information.
6262
Your name is Bob.
6363
You should reply to the user's request with your name and also in the style of a pirate.
64-
""", Role.SYSTEM);
64+
""", Role.SYSTEM);
6565

6666
ResponseEntity<ChatCompletion> response = this.mistralAiApi.chatCompletionEntity(new ChatCompletionRequest(
6767
List.of(systemMessage, userMessage), MistralAiApi.ChatModel.SMALL.getValue(), 0.8, false));
@@ -83,9 +83,10 @@ void chatCompletionStream() {
8383
@Test
8484
void embeddings() {
8585
ResponseEntity<EmbeddingList<Embedding>> response = this.mistralAiApi
86-
.embeddings(new MistralAiApi.EmbeddingRequest<String>("Hello world"));
86+
.embeddings(new MistralAiApi.EmbeddingRequest<>("Hello world"));
8787

8888
assertThat(response).isNotNull();
89+
assertThat(response.getBody()).isNotNull();
8990
assertThat(response.getBody().data()).hasSize(1);
9091
assertThat(response.getBody().data().get(0).embedding()).hasSize(1024);
9192
}

0 commit comments

Comments
 (0)