Record Class DeepSeekApi.ChatCompletionRequest
java.lang.Object
java.lang.Record
org.springframework.ai.deepseek.api.DeepSeekApi.ChatCompletionRequest
- Record Components:
messages- A list of messages comprising the conversation so far.model- ID of the model to use.frequencyPenalty- Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.maxTokens- The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API. This value is now deprecated in favor of max_completion_tokens, and is not compatible with o1 series models.presencePenalty- Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.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.stop- A string or a list containing up to 4 strings, upon encountering these words, the API will cease generating more tokens.stream- If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.temperature- What sampling temperature to use, between 0 and 2. 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- An alternative to sampling with temperature, called 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.logprobs- Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.topLogprobs- An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.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. Specifying a particular function via {"type": "function", "function": {"name": "my_function"}} forces the model to call that function. none is the default when no functions are present. auto is the default if functions are present. Use theDeepSeekApi.ChatCompletionRequest.ToolChoiceBuilderto create the tool choice value.
- Enclosing class:
- DeepSeekApi
public static record DeepSeekApi.ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double frequencyPenalty, Integer maxTokens, Double presencePenalty, ResponseFormat responseFormat, List<String> stop, Boolean stream, Double temperature, Double topP, Boolean logprobs, Integer topLogprobs, List<DeepSeekApi.FunctionTool> tools, Object toolChoice)
extends Record
Creates a model response for the given chat conversation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper factory that creates a tool_choice of type 'none', 'auto' or selected function by name. -
Constructor Summary
ConstructorsConstructorDescriptionChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, Boolean stream) Shortcut constructor for a chat completion request with the given messages for streaming.ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model, temperature and control for streaming.ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double frequencyPenalty, Integer maxTokens, Double presencePenalty, ResponseFormat responseFormat, List<String> stop, Boolean stream, Double temperature, Double topP, Boolean logprobs, Integer topLogprobs, List<DeepSeekApi.FunctionTool> tools, Object toolChoice) Creates an instance of aChatCompletionRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of thefrequencyPenaltyrecord component.final inthashCode()Returns a hash code value for this object.logprobs()Returns the value of thelogprobsrecord component.Returns the value of themaxTokensrecord component.messages()Returns the value of themessagesrecord component.model()Returns the value of themodelrecord component.Returns the value of thepresencePenaltyrecord component.Returns the value of theresponseFormatrecord component.stop()Returns the value of thestoprecord component.stream()Returns the value of thestreamrecord component.Returns the value of thetemperaturerecord component.Returns the value of thetoolChoicerecord component.tools()Returns the value of thetoolsrecord component.Returns the value of thetopLogprobsrecord component.topP()Returns the value of thetopPrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ChatCompletionRequest
Shortcut constructor for a chat completion request with the given messages for streaming.- Parameters:
messages- A list of messages comprising the conversation so far.stream- If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
-
ChatCompletionRequest
public ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.- Parameters:
messages- A list of messages comprising the conversation so far.model- ID of the model to use.temperature- What sampling temperature to use, between 0 and 1.
-
ChatCompletionRequest
public ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model, temperature and control for streaming.- Parameters:
messages- A list of messages comprising the conversation so far.model- ID of the model to use.temperature- What sampling temperature to use, between 0 and 1.stream- If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
-
ChatCompletionRequest
public ChatCompletionRequest(List<DeepSeekApi.ChatCompletionMessage> messages, String model, Double frequencyPenalty, Integer maxTokens, Double presencePenalty, ResponseFormat responseFormat, List<String> stop, Boolean stream, Double temperature, Double topP, Boolean logprobs, Integer topLogprobs, List<DeepSeekApi.FunctionTool> tools, Object toolChoice) Creates an instance of aChatCompletionRequestrecord class.- Parameters:
messages- the value for themessagesrecord componentmodel- the value for themodelrecord componentfrequencyPenalty- the value for thefrequencyPenaltyrecord componentmaxTokens- the value for themaxTokensrecord componentpresencePenalty- the value for thepresencePenaltyrecord componentresponseFormat- the value for theresponseFormatrecord componentstop- the value for thestoprecord componentstream- the value for thestreamrecord componenttemperature- the value for thetemperaturerecord componenttopP- the value for thetopPrecord componentlogprobs- the value for thelogprobsrecord componenttopLogprobs- the value for thetopLogprobsrecord componenttools- the value for thetoolsrecord componenttoolChoice- the value for thetoolChoicerecord 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). -
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
frequencyPenalty
Returns the value of thefrequencyPenaltyrecord component.- Returns:
- the value of the
frequencyPenaltyrecord component
-
maxTokens
Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
presencePenalty
Returns the value of thepresencePenaltyrecord component.- Returns:
- the value of the
presencePenaltyrecord component
-
responseFormat
Returns the value of theresponseFormatrecord component.- Returns:
- the value of the
responseFormatrecord component
-
stop
Returns the value of thestoprecord component.- Returns:
- the value of the
stoprecord component
-
stream
Returns the value of thestreamrecord component.- Returns:
- the value of the
streamrecord component
-
temperature
Returns the value of thetemperaturerecord component.- Returns:
- the value of the
temperaturerecord component
-
topP
Returns the value of thetopPrecord component.- Returns:
- the value of the
topPrecord component
-
logprobs
Returns the value of thelogprobsrecord component.- Returns:
- the value of the
logprobsrecord component
-
topLogprobs
Returns the value of thetopLogprobsrecord component.- Returns:
- the value of the
topLogprobsrecord component
-
tools
Returns the value of thetoolsrecord component.- Returns:
- the value of the
toolsrecord component
-
toolChoice
Returns the value of thetoolChoicerecord component.- Returns:
- the value of the
toolChoicerecord component
-