Package org.springframework.ai.mistralai
Class MistralAiChatModel
java.lang.Object
org.springframework.ai.mistralai.MistralAiChatModel
- All Implemented Interfaces:
ChatModel,StreamingChatModel,Model<Prompt,,ChatResponse> StreamingModel<Prompt,ChatResponse>
Represents a Mistral AI Chat Model.
The assistant message of each choice is built from ordered MessageParts that
follow the content chunks Mistral returns: a text chunk, or a plain string content,
becomes a TextPart, a thinking chunk a ReasoningPart, and any other
chunk, such as the reference of a citation, an UnknownPart that holds it
verbatim. Tool calls are a separate field of a Mistral message, so their
ToolCallParts always follow the content.
An assistant message that carries Mistral reasoning or other Mistral chunks is replayed as content chunks in part order, so a reasoning model gets its earlier thinking back next to the answer it led to, as Mistral recommends. Any other assistant message is sent as its text, as before.
- Since:
- 1.0.0
- Author:
- Ricken Bazolo, Christian Tzolov, Grogdunn, Thomas Vitale, luocongqiu, Ilayaperumal Gopinathan, Alexandros Pappas, Nicolas Krier, Jason Smith, Sebastien Deleuze, Dimitar Proynov
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMistralAiChatModel(MistralAiApi mistralAiApi, MistralAiChatOptions options, ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) -
Method Summary
Modifier and TypeMethodDescriptionstatic MistralAiChatModel.Builderbuilder()Executes a method call to the AI model.static ChatResponseMetadatafrom(MistralAiApi.ChatCompletion result) static ChatResponseMetadatafrom(MistralAiApi.ChatCompletion result, Usage usage) Gets the chat options for this model.voidsetObservationConvention(ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<ChatResponse>Executes a method call to the AI model.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.model.ChatModel
call, call, getDefaultOptionsMethods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Field Details
-
REFERENCE_CONTENT_METADATA
- See Also:
-
REFERENCE_THINKING_CONTENT_METADATA
- See Also:
-
THINKING_CONTENT_METADATA
Deprecated, for removal: This API element is subject to removal in a future version.since 2.1.0 in favor ofAssistantMessage.getReasoning()Key of the thinking text in the message metadata. Superseded by theReasoningParts of the message, seeAssistantMessage.getReasoning(). Still written for backward compatibility, and read on replay only from an assistant message without reasoning parts, such as one built by an earlier version. Unlike the text of aReasoningPart, it joins the text chunks of the thinking with a line separator.- See Also:
-
SIGNATURE_PAYLOAD_KIND
Thekindof the payload that holds the signature of a thinking chunk.- Since:
- 2.1.0
- See Also:
-
-
Constructor Details
-
MistralAiChatModel
public MistralAiChatModel(MistralAiApi mistralAiApi, MistralAiChatOptions options, ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
-
-
Method Details
-
from
-
from
-
call
Description copied from interface:ModelExecutes a method call to the AI model. -
stream
Description copied from interface:StreamingModelExecutes a method call to the AI model.- Specified by:
streamin interfaceChatModel- Specified by:
streamin interfaceStreamingChatModel- Specified by:
streamin interfaceStreamingModel<Prompt,ChatResponse> - Parameters:
prompt- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
getOptions
Description copied from interface:ChatModelGets the chat options for this model.- Specified by:
getOptionsin interfaceChatModel- Returns:
- the chat options
- Since:
- 2.0.0
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-
builder
-
AssistantMessage.getReasoning()