Package org.springframework.ai.openaisdk
Class OpenAiSdkChatOptions
java.lang.Object
org.springframework.ai.openaisdk.AbstractOpenAiSdkOptions
org.springframework.ai.openaisdk.OpenAiSdkChatOptions
- All Implemented Interfaces:
ChatOptions,ModelOptions,StructuredOutputChatOptions,ToolCallingChatOptions
public class OpenAiSdkChatOptions
extends AbstractOpenAiSdkOptions
implements ToolCallingChatOptions, StructuredOutputChatOptions
Configuration information for the Chat Model implementation using the OpenAI Java SDK.
- Author:
- Julien Dubois, Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final classstatic final record -
Field Summary
FieldsFields inherited from interface org.springframework.ai.model.tool.ToolCallingChatOptions
DEFAULT_TOOL_EXECUTION_ENABLED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiSdkChatOptions.Builderbuilder()A builder to create a newToolCallingChatOptionsinstance.copy()Returns a copy of thisChatOptions.booleanGets the frequency penalty parameter.Whether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.Gets the logit bias map.Gets whether to return log probabilities.Gets the maximum number of completion tokens.Returns the maximum number of tokens to use for the chat.Gets the metadata map.getN()Gets the number of completions to generate.Gets the output audio parameters.Gets the output modalities.Gets whether to enable parallel tool calls.Returns the presence penalty to use for the chat.Gets the reasoning effort level.Gets the response format configuration.getSeed()Gets the random seed for deterministic generation.Gets the service tier.getStop()Gets the stop sequences.Returns the stop sequences to use for the chat.getStore()Gets whether to store the conversation.Gets the stream options.Returns the temperature to use for the chat.ToolCallbacks to be registered with the ChatModel.Gets the tool choice configuration.Get the configured tool context.Names of the tools to register with the ChatModel.getTopK()Returns the top K to use for the chat.Gets the number of top log probabilities to return.getTopP()Returns the top P to use for the chat.getUser()Gets the user identifier.Gets the verbosity level.inthashCode()voidsetFrequencyPenalty(Double frequencyPenalty) Sets the frequency penalty parameter.voidsetInternalToolExecutionEnabled(Boolean internalToolExecutionEnabled) Set whether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.voidsetLogitBias(Map<String, Integer> logitBias) Sets the logit bias map.voidsetLogprobs(Boolean logprobs) Sets whether to return log probabilities.voidsetMaxCompletionTokens(Integer maxCompletionTokens) Sets the maximum number of completion tokens.voidsetMaxTokens(Integer maxTokens) Sets the maximum number of tokens to generate.voidsetMetadata(Map<String, String> metadata) Sets the metadata map.voidSets the number of completions to generate.voidsetOutputAudio(OpenAiSdkChatOptions.AudioParameters outputAudio) Sets the output audio parameters.voidsetOutputModalities(List<String> outputModalities) Sets the output modalities.voidsetOutputSchema(String outputSchema) voidsetParallelToolCalls(Boolean parallelToolCalls) Sets whether to enable parallel tool calls.voidsetPresencePenalty(Double presencePenalty) Sets the presence penalty parameter.voidsetReasoningEffort(String reasoningEffort) Sets the reasoning effort level.voidsetResponseFormat(OpenAiSdkChatModel.ResponseFormat responseFormat) Sets the response format configuration.voidSets the random seed for deterministic generation.voidsetServiceTier(String serviceTier) Sets the service tier.voidSets the stop sequences.voidsetStopSequences(List<String> stopSequences) Sets the stop sequences.voidSets whether to store the conversation.voidsetStreamOptions(OpenAiSdkChatOptions.StreamOptions streamOptions) Sets the stream options.voidsetTemperature(Double temperature) Sets the temperature for sampling.voidsetToolCallbacks(List<ToolCallback> toolCallbacks) Set the ToolCallbacks to be registered with the ChatModel.voidsetToolChoice(Object toolChoice) Sets the tool choice configuration.voidsetToolContext(Map<String, Object> toolContext) Set the tool context values as map.voidsetToolNames(Set<String> toolNames) Set the names of the tools to register with the ChatModel.voidsetTopLogprobs(Integer topLogprobs) Sets the number of top log probabilities to return.voidSets the top-p nucleus sampling parameter.voidSets the user identifier.voidsetVerbosity(String verbosity) Sets the verbosity level.toString()Methods inherited from class org.springframework.ai.openaisdk.AbstractOpenAiSdkOptions
getApiKey, getBaseUrl, getCredential, getCustomHeaders, getDeploymentName, getMaxRetries, getMicrosoftDeploymentName, getMicrosoftFoundryServiceVersion, getModel, getOrganizationId, getProxy, getTimeout, isGitHubModels, isMicrosoftFoundry, setApiKey, setBaseUrl, setCredential, setCustomHeaders, setDeploymentName, setGitHubModels, setMaxRetries, setMicrosoftDeploymentName, setMicrosoftFoundry, setMicrosoftFoundryServiceVersion, setModel, setOrganizationId, setProxy, setTimeoutMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.prompt.ChatOptions
getModel
-
Field Details
-
DEFAULT_CHAT_MODEL
-
-
Constructor Details
-
OpenAiSdkChatOptions
public OpenAiSdkChatOptions()
-
-
Method Details
-
getFrequencyPenalty
Gets the frequency penalty parameter.- Specified by:
getFrequencyPenaltyin interfaceChatOptions- Returns:
- the frequency penalty
-
setFrequencyPenalty
Sets the frequency penalty parameter.- Parameters:
frequencyPenalty- the frequency penalty to set
-
getLogitBias
Gets the logit bias map.- Returns:
- the logit bias map
-
setLogitBias
Sets the logit bias map.- Parameters:
logitBias- the logit bias map to set
-
getLogprobs
Gets whether to return log probabilities.- Returns:
- true if log probabilities should be returned
-
setLogprobs
Sets whether to return log probabilities.- Parameters:
logprobs- whether to return log probabilities
-
getTopLogprobs
Gets the number of top log probabilities to return.- Returns:
- the number of top log probabilities
-
setTopLogprobs
Sets the number of top log probabilities to return.- Parameters:
topLogprobs- the number of top log probabilities
-
getMaxTokens
Description copied from interface:ChatOptionsReturns the maximum number of tokens to use for the chat.- Specified by:
getMaxTokensin interfaceChatOptions- Returns:
- the maximum number of tokens to use for the chat
-
setMaxTokens
Sets the maximum number of tokens to generate.- Parameters:
maxTokens- the maximum number of tokens
-
getMaxCompletionTokens
Gets the maximum number of completion tokens.- Returns:
- the maximum number of completion tokens
-
setMaxCompletionTokens
Sets the maximum number of completion tokens.- Parameters:
maxCompletionTokens- the maximum number of completion tokens
-
getN
Gets the number of completions to generate.- Returns:
- the number of completions
-
setN
Sets the number of completions to generate.- Parameters:
n- the number of completions
-
getOutputModalities
Gets the output modalities.- Returns:
- the output modalities
-
setOutputModalities
Sets the output modalities.- Parameters:
outputModalities- the output modalities
-
getOutputAudio
Gets the output audio parameters.- Returns:
- the output audio parameters
-
setOutputAudio
Sets the output audio parameters.- Parameters:
outputAudio- the output audio parameters
-
getPresencePenalty
Description copied from interface:ChatOptionsReturns the presence penalty to use for the chat.- Specified by:
getPresencePenaltyin interfaceChatOptions- Returns:
- the presence penalty to use for the chat
-
setPresencePenalty
Sets the presence penalty parameter.- Parameters:
presencePenalty- the presence penalty to set
-
getResponseFormat
Gets the response format configuration.- Returns:
- the response format
-
setResponseFormat
Sets the response format configuration.- Parameters:
responseFormat- the response format to set
-
getStreamOptions
Gets the stream options.- Returns:
- the stream options
-
setStreamOptions
Sets the stream options.- Parameters:
streamOptions- the stream options to set
-
getSeed
Gets the random seed for deterministic generation.- Returns:
- the random seed
-
setSeed
Sets the random seed for deterministic generation.- Parameters:
seed- the random seed
-
getStop
Gets the stop sequences.- Returns:
- the list of stop sequences
-
setStop
Sets the stop sequences.- Parameters:
stop- the list of stop sequences
-
getStopSequences
Description copied from interface:ChatOptionsReturns the stop sequences to use for the chat.- Specified by:
getStopSequencesin interfaceChatOptions- Returns:
- the stop sequences to use for the chat
-
setStopSequences
Sets the stop sequences.- Parameters:
stopSequences- the list of stop sequences
-
getTemperature
Description copied from interface:ChatOptionsReturns the temperature to use for the chat.- Specified by:
getTemperaturein interfaceChatOptions- Returns:
- the temperature to use for the chat
-
setTemperature
Sets the temperature for sampling.- Parameters:
temperature- the temperature value
-
getTopP
Description copied from interface:ChatOptionsReturns the top P to use for the chat.- Specified by:
getTopPin interfaceChatOptions- Returns:
- the top P to use for the chat
-
setTopP
Sets the top-p nucleus sampling parameter.- Parameters:
topP- the top-p value
-
getToolChoice
Gets the tool choice configuration.- Returns:
- the tool choice option
-
setToolChoice
Sets the tool choice configuration.- Parameters:
toolChoice- the tool choice option
-
getUser
Gets the user identifier.- Returns:
- the user identifier
-
setUser
Sets the user identifier.- Parameters:
user- the user identifier
-
getParallelToolCalls
Gets whether to enable parallel tool calls.- Returns:
- true if parallel tool calls are enabled
-
setParallelToolCalls
Sets whether to enable parallel tool calls.- Parameters:
parallelToolCalls- whether to enable parallel tool calls
-
getStore
Gets whether to store the conversation.- Returns:
- true if the conversation should be stored
-
setStore
Sets whether to store the conversation.- Parameters:
store- whether to store the conversation
-
getMetadata
Gets the metadata map.- Returns:
- the metadata map
-
setMetadata
Sets the metadata map.- Parameters:
metadata- the metadata map
-
getReasoningEffort
Gets the reasoning effort level.- Returns:
- the reasoning effort level
-
setReasoningEffort
Sets the reasoning effort level.- Parameters:
reasoningEffort- the reasoning effort level
-
getVerbosity
Gets the verbosity level.- Returns:
- the verbosity level
-
setVerbosity
Sets the verbosity level.- Parameters:
verbosity- the verbosity level
-
getServiceTier
Gets the service tier.- Returns:
- the service tier
-
setServiceTier
Sets the service tier.- Parameters:
serviceTier- the service tier
-
getToolCallbacks
Description copied from interface:ToolCallingChatOptionsToolCallbacks to be registered with the ChatModel.- Specified by:
getToolCallbacksin interfaceToolCallingChatOptions
-
setToolCallbacks
Description copied from interface:ToolCallingChatOptionsSet the ToolCallbacks to be registered with the ChatModel.- Specified by:
setToolCallbacksin interfaceToolCallingChatOptions
-
getToolNames
Description copied from interface:ToolCallingChatOptionsNames of the tools to register with the ChatModel.- Specified by:
getToolNamesin interfaceToolCallingChatOptions
-
setToolNames
Description copied from interface:ToolCallingChatOptionsSet the names of the tools to register with the ChatModel.- Specified by:
setToolNamesin interfaceToolCallingChatOptions
-
getInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptionsWhether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.- Specified by:
getInternalToolExecutionEnabledin interfaceToolCallingChatOptions
-
setInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptionsSet whether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.- Specified by:
setInternalToolExecutionEnabledin interfaceToolCallingChatOptions
-
getToolContext
Description copied from interface:ToolCallingChatOptionsGet the configured tool context.- Specified by:
getToolContextin interfaceToolCallingChatOptions- Returns:
- the tool context map.
-
setToolContext
Description copied from interface:ToolCallingChatOptionsSet the tool context values as map.- Specified by:
setToolContextin interfaceToolCallingChatOptions- Parameters:
toolContext- as map
-
getTopK
Description copied from interface:ChatOptionsReturns the top K to use for the chat.- Specified by:
getTopKin interfaceChatOptions- Returns:
- the top K to use for the chat
-
getOutputSchema
- Specified by:
getOutputSchemain interfaceStructuredOutputChatOptions
-
setOutputSchema
- Specified by:
setOutputSchemain interfaceStructuredOutputChatOptions
-
builder
Description copied from interface:ToolCallingChatOptionsA builder to create a newToolCallingChatOptionsinstance.- Returns:
- Returns a new
ChatOptions.Builder.
-
copy
Description copied from interface:ChatOptionsReturns a copy of thisChatOptions.- Specified by:
copyin interfaceChatOptions- Returns:
- a copy of this
ChatOptions
-
equals
-
hashCode
public int hashCode() -
toString
-