Record Class MistralAiApi.ChatCompletionRequest
java.lang.Object
java.lang.Record
org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest
- Record Components:
model
- ID of the model to use.messages
- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.tools
- A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.toolChoice
- Controls which (if any) function is called by the model. none means the model will not call a function and instead generates a message. auto means the model can pick between generating a message or calling a function. Any means the model must call a function.temperature
- What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.topP
- Nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.maxTokens
- The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length.stream
- Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.safePrompt
- Whether to inject a safety prompt before all conversations.stop
- A list of tokens that the model should stop generating after. If set,randomSeed
- The seed to use for random sampling. If set, different calls will generate deterministic results.responseFormat
- An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
- Enclosing class:
- MistralAiApi
public static record MistralAiApi.ChatCompletionRequest(String model, List<MistralAiApi.ChatCompletionMessage> messages, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, Double temperature, Double topP, Integer maxTokens, Boolean stream, Boolean safePrompt, List<String> stop, Integer randomSeed, MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat)
extends Record
Creates a model request for chat conversation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
An object specifying the format that the model must output.static enum
Specifies a tool the model should use. -
Constructor Summary
ConstructorDescriptionChatCompletionRequest
(String model, List<MistralAiApi.ChatCompletionMessage> messages, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, Double temperature, Double topP, Integer maxTokens, Boolean stream, Boolean safePrompt, List<String> stop, Integer randomSeed, MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat) Creates an instance of aChatCompletionRequest
record class.ChatCompletionRequest
(List<MistralAiApi.ChatCompletionMessage> messages, Boolean stream) Shortcut constructor for a chat completion request with the given messages and stream.ChatCompletionRequest
(List<MistralAiApi.ChatCompletionMessage> messages, String model) Shortcut constructor for a chat completion request with the given messages and model.ChatCompletionRequest
(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.ChatCompletionRequest
(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model and temperature.ChatCompletionRequest
(List<MistralAiApi.ChatCompletionMessage> messages, String model, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice) Shortcut constructor for a chat completion request with the given messages, model, tools and tool choice. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of themaxTokens
record component.messages()
Returns the value of themessages
record component.model()
Returns the value of themodel
record component.Returns the value of therandomSeed
record component.Returns the value of theresponseFormat
record component.Returns the value of thesafePrompt
record component.stop()
Returns the value of thestop
record component.stream()
Returns the value of thestream
record component.Returns the value of thetemperature
record component.Returns the value of thetoolChoice
record component.tools()
Returns the value of thetools
record component.topP()
Returns the value of thetopP
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
ChatCompletionRequest
Shortcut constructor for a chat completion request with the given messages and model.- Parameters:
messages
- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model
- ID of the model to use.
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model and temperature.- Parameters:
messages
- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model
- ID of the model to use.temperature
- What sampling temperature to use, between 0.0 and 1.0.stream
- Whether to stream back partial progress. If set, tokens will be sent
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.- Parameters:
messages
- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model
- ID of the model to use.temperature
- What sampling temperature to use, between 0.0 and 1.0.
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice) Shortcut constructor for a chat completion request with the given messages, model, tools and tool choice. Streaming is set to false, temperature to 0.8 and all other parameters are null.- Parameters:
messages
- A list of messages comprising the conversation so far.model
- ID of the model to use.tools
- A list of tools the model may call. Currently, only functions are supported as a tool.toolChoice
- Controls which (if any) function is called by the model.
-
ChatCompletionRequest
Shortcut constructor for a chat completion request with the given messages and stream. -
ChatCompletionRequest
public ChatCompletionRequest(String model, List<MistralAiApi.ChatCompletionMessage> messages, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, Double temperature, Double topP, Integer maxTokens, Boolean stream, Boolean safePrompt, List<String> stop, Integer randomSeed, MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat) Creates an instance of aChatCompletionRequest
record class.- Parameters:
model
- the value for themodel
record componentmessages
- the value for themessages
record componenttools
- the value for thetools
record componenttoolChoice
- the value for thetoolChoice
record componenttemperature
- the value for thetemperature
record componenttopP
- the value for thetopP
record componentmaxTokens
- the value for themaxTokens
record componentstream
- the value for thestream
record componentsafePrompt
- the value for thesafePrompt
record componentstop
- the value for thestop
record componentrandomSeed
- the value for therandomSeed
record componentresponseFormat
- the value for theresponseFormat
record component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
model
Returns the value of themodel
record component.- Returns:
- the value of the
model
record component
-
messages
Returns the value of themessages
record component.- Returns:
- the value of the
messages
record component
-
tools
Returns the value of thetools
record component.- Returns:
- the value of the
tools
record component
-
toolChoice
Returns the value of thetoolChoice
record component.- Returns:
- the value of the
toolChoice
record component
-
temperature
Returns the value of thetemperature
record component.- Returns:
- the value of the
temperature
record component
-
topP
Returns the value of thetopP
record component.- Returns:
- the value of the
topP
record component
-
maxTokens
Returns the value of themaxTokens
record component.- Returns:
- the value of the
maxTokens
record component
-
stream
Returns the value of thestream
record component.- Returns:
- the value of the
stream
record component
-
safePrompt
Returns the value of thesafePrompt
record component.- Returns:
- the value of the
safePrompt
record component
-
stop
Returns the value of thestop
record component.- Returns:
- the value of the
stop
record component
-
randomSeed
Returns the value of therandomSeed
record component.- Returns:
- the value of the
randomSeed
record component
-
responseFormat
Returns the value of theresponseFormat
record component.- Returns:
- the value of the
responseFormat
record component
-