[Mistral] Update models
* Align model naming with Mistral AI documentation * Add missing model for mixtral 22B * Deprecate mistral-medium-latest because Mistral will remove it soon Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
This commit is contained in:
committed by
Christian Tzolov
parent
3cac679223
commit
1eb61efc50
@@ -53,6 +53,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @author Ricken Bazolo
|
||||
* @author Christian Tzolov
|
||||
* @author Grogdunn
|
||||
* @author Thomas Vitale
|
||||
* @since 0.8.1
|
||||
*/
|
||||
public class MistralAiChatModel extends
|
||||
@@ -79,7 +80,7 @@ public class MistralAiChatModel extends
|
||||
.withTemperature(0.7f)
|
||||
.withTopP(1f)
|
||||
.withSafePrompt(false)
|
||||
.withModel(MistralAiApi.ChatModel.TINY.getValue())
|
||||
.withModel(MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue())
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
*
|
||||
* @author Ricken Bazolo
|
||||
* @author Christian Tzolov
|
||||
* @author Thomas Vitale
|
||||
* @since 0.8.1
|
||||
*/
|
||||
public class MistralAiApi {
|
||||
@@ -696,23 +697,22 @@ public class MistralAiApi {
|
||||
* https://docs.mistral.ai/platform/endpoints/#mistral-ai-generative-models
|
||||
*
|
||||
* <p>
|
||||
* Mistral AI provides five API endpoints featuring five leading Large Language
|
||||
* Models:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li><b>TINY</b> - open-mistral-7b (aka mistral-tiny-2312)</li>
|
||||
* <li><b>MIXTRAL</b> - open-mixtral-8x7b (aka mistral-small-2312)</li>
|
||||
* <li><b>SMALL_LATEST</b> - mistral-small-latest (aka mistral-small-2402)</li>
|
||||
* <li><b>MEDIUM</b> - mistral-medium-latest (aka mistral-medium-2312)</li>
|
||||
* <li><b>LARGE</b> - mistral-large-latest (aka mistral-large-2402)</li>
|
||||
* </ul>
|
||||
* Mistral AI provides two types of models: open-weights models (Mistral 7B, Mixtral
|
||||
* 8x7B, Mixtral 8x22B) and optimized commercial models (Mistral Small, Mistral
|
||||
* Medium, Mistral Large, and Mistral Embeddings).
|
||||
*/
|
||||
public enum ChatModel implements ModelDescription {
|
||||
|
||||
// @formatter:off
|
||||
@Deprecated(since = "1.0.0-M1", forRemoval = true) // Replaced by OPEN_MISTRAL_7B
|
||||
TINY("open-mistral-7b"),
|
||||
@Deprecated(since = "1.0.0-M1", forRemoval = true) // Replaced by OPEN_MIXTRAL_7B
|
||||
MIXTRAL("open-mixtral-8x7b"),
|
||||
OPEN_MISTRAL_7B("open-mistral-7b"),
|
||||
OPEN_MIXTRAL_7B("open-mixtral-8x7b"),
|
||||
OPEN_MIXTRAL_22B("open-mixtral-8x22b"),
|
||||
SMALL("mistral-small-latest"),
|
||||
@Deprecated(since = "1.0.0-M1", forRemoval = true) // Mistral is removing this model
|
||||
MEDIUM("mistral-medium-latest"),
|
||||
LARGE("mistral-large-latest");
|
||||
// @formatter:on
|
||||
@@ -741,7 +741,7 @@ public class MistralAiApi {
|
||||
public enum EmbeddingModel {
|
||||
|
||||
// @formatter:off
|
||||
@JsonProperty("mistral-embed") EMBED("mistral-embed");
|
||||
EMBED("mistral-embed");
|
||||
// @formatter:on
|
||||
|
||||
private final String value;
|
||||
|
||||
@@ -52,12 +52,13 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Christian Tzolov
|
||||
* @author Thomas Vitale
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class MistralAiRetryTests {
|
||||
|
||||
private class TestRetryListener implements RetryListener {
|
||||
private static class TestRetryListener implements RetryListener {
|
||||
|
||||
int onErrorRetryCount = 0;
|
||||
|
||||
@@ -97,7 +98,7 @@ public class MistralAiRetryTests {
|
||||
.withTemperature(0.7f)
|
||||
.withTopP(1f)
|
||||
.withSafePrompt(false)
|
||||
.withModel(MistralAiApi.ChatModel.TINY.getValue())
|
||||
.withModel(MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue())
|
||||
.build(),
|
||||
null, retryTemplate);
|
||||
embeddingModel = new MistralAiEmbeddingModel(mistralAiApi, MetadataMode.EMBED,
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MistralAiTestConfiguration {
|
||||
@Bean
|
||||
public MistralAiChatModel mistralAiChatModel(MistralAiApi mistralAiApi) {
|
||||
return new MistralAiChatModel(mistralAiApi,
|
||||
MistralAiChatOptions.builder().withModel(MistralAiApi.ChatModel.MIXTRAL.getValue()).build());
|
||||
MistralAiChatOptions.builder().withModel(MistralAiApi.ChatModel.OPEN_MIXTRAL_7B.getValue()).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Christian Tzolov
|
||||
* @author Thomas Vitale
|
||||
* @since 0.8.1
|
||||
*/
|
||||
@EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+")
|
||||
@@ -45,7 +46,7 @@ public class MistralAiApiIT {
|
||||
void chatCompletionEntity() {
|
||||
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Hello world", Role.USER);
|
||||
ResponseEntity<ChatCompletion> response = mistralAiApi.chatCompletionEntity(new ChatCompletionRequest(
|
||||
List.of(chatCompletionMessage), MistralAiApi.ChatModel.TINY.getValue(), 0.8f, false));
|
||||
List.of(chatCompletionMessage), MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue(), 0.8f, false));
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
@@ -62,7 +63,7 @@ public class MistralAiApiIT {
|
||||
""", Role.SYSTEM);
|
||||
|
||||
ResponseEntity<ChatCompletion> response = mistralAiApi.chatCompletionEntity(new ChatCompletionRequest(
|
||||
List.of(systemMessage, userMessage), MistralAiApi.ChatModel.TINY.getValue(), 0.8f, false));
|
||||
List.of(systemMessage, userMessage), MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue(), 0.8f, false));
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
@@ -72,7 +73,7 @@ public class MistralAiApiIT {
|
||||
void chatCompletionStream() {
|
||||
ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Hello world", Role.USER);
|
||||
Flux<ChatCompletionChunk> response = mistralAiApi.chatCompletionStream(new ChatCompletionRequest(
|
||||
List.of(chatCompletionMessage), MistralAiApi.ChatModel.TINY.getValue(), 0.8f, true));
|
||||
List.of(chatCompletionMessage), MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue(), 0.8f, true));
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.collectList().block()).isNotNull();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
/**
|
||||
* @author Ricken Bazolo
|
||||
* @author Christian Tzolov
|
||||
* @author Thomas Vitale
|
||||
* @since 0.8.1
|
||||
*/
|
||||
@ConfigurationProperties(MistralAiChatProperties.CONFIG_PREFIX)
|
||||
@@ -30,7 +31,7 @@ public class MistralAiChatProperties extends MistralAiParentProperties {
|
||||
|
||||
public static final String CONFIG_PREFIX = "spring.ai.mistralai.chat";
|
||||
|
||||
public static final String DEFAULT_CHAT_MODEL = MistralAiApi.ChatModel.TINY.getValue();
|
||||
public static final String DEFAULT_CHAT_MODEL = MistralAiApi.ChatModel.OPEN_MISTRAL_7B.getValue();
|
||||
|
||||
private static final Double DEFAULT_TEMPERATURE = 0.7;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user