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
  • Field Details

    • DEFAULT_CHAT_MODEL

      public static final String DEFAULT_CHAT_MODEL
  • Constructor Details

    • OpenAiSdkChatOptions

      public OpenAiSdkChatOptions()
  • Method Details

    • getFrequencyPenalty

      public Double getFrequencyPenalty()
      Gets the frequency penalty parameter.
      Specified by:
      getFrequencyPenalty in interface ChatOptions
      Returns:
      the frequency penalty
    • setFrequencyPenalty

      public void setFrequencyPenalty(Double frequencyPenalty)
      Sets the frequency penalty parameter.
      Parameters:
      frequencyPenalty - the frequency penalty to set
    • getLogitBias

      public Map<String,Integer> getLogitBias()
      Gets the logit bias map.
      Returns:
      the logit bias map
    • setLogitBias

      public void setLogitBias(Map<String,Integer> logitBias)
      Sets the logit bias map.
      Parameters:
      logitBias - the logit bias map to set
    • getLogprobs

      public Boolean getLogprobs()
      Gets whether to return log probabilities.
      Returns:
      true if log probabilities should be returned
    • setLogprobs

      public void setLogprobs(Boolean logprobs)
      Sets whether to return log probabilities.
      Parameters:
      logprobs - whether to return log probabilities
    • getTopLogprobs

      public Integer getTopLogprobs()
      Gets the number of top log probabilities to return.
      Returns:
      the number of top log probabilities
    • setTopLogprobs

      public void setTopLogprobs(Integer topLogprobs)
      Sets the number of top log probabilities to return.
      Parameters:
      topLogprobs - the number of top log probabilities
    • getMaxTokens

      public Integer getMaxTokens()
      Description copied from interface: ChatOptions
      Returns the maximum number of tokens to use for the chat.
      Specified by:
      getMaxTokens in interface ChatOptions
      Returns:
      the maximum number of tokens to use for the chat
    • setMaxTokens

      public void setMaxTokens(Integer maxTokens)
      Sets the maximum number of tokens to generate.
      Parameters:
      maxTokens - the maximum number of tokens
    • getMaxCompletionTokens

      public Integer getMaxCompletionTokens()
      Gets the maximum number of completion tokens.
      Returns:
      the maximum number of completion tokens
    • setMaxCompletionTokens

      public void setMaxCompletionTokens(Integer maxCompletionTokens)
      Sets the maximum number of completion tokens.
      Parameters:
      maxCompletionTokens - the maximum number of completion tokens
    • getN

      public Integer getN()
      Gets the number of completions to generate.
      Returns:
      the number of completions
    • setN

      public void setN(Integer n)
      Sets the number of completions to generate.
      Parameters:
      n - the number of completions
    • getOutputModalities

      public List<String> getOutputModalities()
      Gets the output modalities.
      Returns:
      the output modalities
    • setOutputModalities

      public void setOutputModalities(List<String> outputModalities)
      Sets the output modalities.
      Parameters:
      outputModalities - the output modalities
    • getOutputAudio

      public OpenAiSdkChatOptions.AudioParameters getOutputAudio()
      Gets the output audio parameters.
      Returns:
      the output audio parameters
    • setOutputAudio

      public void setOutputAudio(OpenAiSdkChatOptions.AudioParameters outputAudio)
      Sets the output audio parameters.
      Parameters:
      outputAudio - the output audio parameters
    • getPresencePenalty

      public Double getPresencePenalty()
      Description copied from interface: ChatOptions
      Returns the presence penalty to use for the chat.
      Specified by:
      getPresencePenalty in interface ChatOptions
      Returns:
      the presence penalty to use for the chat
    • setPresencePenalty

      public void setPresencePenalty(Double presencePenalty)
      Sets the presence penalty parameter.
      Parameters:
      presencePenalty - the presence penalty to set
    • getResponseFormat

      public OpenAiSdkChatModel.ResponseFormat getResponseFormat()
      Gets the response format configuration.
      Returns:
      the response format
    • setResponseFormat

      public void setResponseFormat(OpenAiSdkChatModel.ResponseFormat responseFormat)
      Sets the response format configuration.
      Parameters:
      responseFormat - the response format to set
    • getStreamOptions

      public OpenAiSdkChatOptions.StreamOptions getStreamOptions()
      Gets the stream options.
      Returns:
      the stream options
    • setStreamOptions

      public void setStreamOptions(OpenAiSdkChatOptions.StreamOptions streamOptions)
      Sets the stream options.
      Parameters:
      streamOptions - the stream options to set
    • getSeed

      public Integer getSeed()
      Gets the random seed for deterministic generation.
      Returns:
      the random seed
    • setSeed

      public void setSeed(Integer seed)
      Sets the random seed for deterministic generation.
      Parameters:
      seed - the random seed
    • getStop

      public List<String> getStop()
      Gets the stop sequences.
      Returns:
      the list of stop sequences
    • setStop

      public void setStop(List<String> stop)
      Sets the stop sequences.
      Parameters:
      stop - the list of stop sequences
    • getStopSequences

      public List<String> getStopSequences()
      Description copied from interface: ChatOptions
      Returns the stop sequences to use for the chat.
      Specified by:
      getStopSequences in interface ChatOptions
      Returns:
      the stop sequences to use for the chat
    • setStopSequences

      public void setStopSequences(List<String> stopSequences)
      Sets the stop sequences.
      Parameters:
      stopSequences - the list of stop sequences
    • getTemperature

      public Double getTemperature()
      Description copied from interface: ChatOptions
      Returns the temperature to use for the chat.
      Specified by:
      getTemperature in interface ChatOptions
      Returns:
      the temperature to use for the chat
    • setTemperature

      public void setTemperature(Double temperature)
      Sets the temperature for sampling.
      Parameters:
      temperature - the temperature value
    • getTopP

      public Double getTopP()
      Description copied from interface: ChatOptions
      Returns the top P to use for the chat.
      Specified by:
      getTopP in interface ChatOptions
      Returns:
      the top P to use for the chat
    • setTopP

      public void setTopP(Double topP)
      Sets the top-p nucleus sampling parameter.
      Parameters:
      topP - the top-p value
    • getToolChoice

      public Object getToolChoice()
      Gets the tool choice configuration.
      Returns:
      the tool choice option
    • setToolChoice

      public void setToolChoice(Object toolChoice)
      Sets the tool choice configuration.
      Parameters:
      toolChoice - the tool choice option
    • getUser

      public String getUser()
      Gets the user identifier.
      Returns:
      the user identifier
    • setUser

      public void setUser(String user)
      Sets the user identifier.
      Parameters:
      user - the user identifier
    • getParallelToolCalls

      public Boolean getParallelToolCalls()
      Gets whether to enable parallel tool calls.
      Returns:
      true if parallel tool calls are enabled
    • setParallelToolCalls

      public void setParallelToolCalls(Boolean parallelToolCalls)
      Sets whether to enable parallel tool calls.
      Parameters:
      parallelToolCalls - whether to enable parallel tool calls
    • getStore

      public Boolean getStore()
      Gets whether to store the conversation.
      Returns:
      true if the conversation should be stored
    • setStore

      public void setStore(Boolean store)
      Sets whether to store the conversation.
      Parameters:
      store - whether to store the conversation
    • getMetadata

      public Map<String,String> getMetadata()
      Gets the metadata map.
      Returns:
      the metadata map
    • setMetadata

      public void setMetadata(Map<String,String> metadata)
      Sets the metadata map.
      Parameters:
      metadata - the metadata map
    • getReasoningEffort

      public String getReasoningEffort()
      Gets the reasoning effort level.
      Returns:
      the reasoning effort level
    • setReasoningEffort

      public void setReasoningEffort(String reasoningEffort)
      Sets the reasoning effort level.
      Parameters:
      reasoningEffort - the reasoning effort level
    • getVerbosity

      public String getVerbosity()
      Gets the verbosity level.
      Returns:
      the verbosity level
    • setVerbosity

      public void setVerbosity(String verbosity)
      Sets the verbosity level.
      Parameters:
      verbosity - the verbosity level
    • getServiceTier

      public String getServiceTier()
      Gets the service tier.
      Returns:
      the service tier
    • setServiceTier

      public void setServiceTier(String serviceTier)
      Sets the service tier.
      Parameters:
      serviceTier - the service tier
    • getToolCallbacks

      public List<ToolCallback> getToolCallbacks()
      Description copied from interface: ToolCallingChatOptions
      ToolCallbacks to be registered with the ChatModel.
      Specified by:
      getToolCallbacks in interface ToolCallingChatOptions
    • setToolCallbacks

      public void setToolCallbacks(List<ToolCallback> toolCallbacks)
      Description copied from interface: ToolCallingChatOptions
      Set the ToolCallbacks to be registered with the ChatModel.
      Specified by:
      setToolCallbacks in interface ToolCallingChatOptions
    • getToolNames

      public Set<String> getToolNames()
      Description copied from interface: ToolCallingChatOptions
      Names of the tools to register with the ChatModel.
      Specified by:
      getToolNames in interface ToolCallingChatOptions
    • setToolNames

      public void setToolNames(Set<String> toolNames)
      Description copied from interface: ToolCallingChatOptions
      Set the names of the tools to register with the ChatModel.
      Specified by:
      setToolNames in interface ToolCallingChatOptions
    • getInternalToolExecutionEnabled

      @Nullable public Boolean getInternalToolExecutionEnabled()
      Description copied from interface: ToolCallingChatOptions
      Whether the ChatModel is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.
      Specified by:
      getInternalToolExecutionEnabled in interface ToolCallingChatOptions
    • setInternalToolExecutionEnabled

      public void setInternalToolExecutionEnabled(@Nullable Boolean internalToolExecutionEnabled)
      Description copied from interface: ToolCallingChatOptions
      Set whether the ChatModel is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.
      Specified by:
      setInternalToolExecutionEnabled in interface ToolCallingChatOptions
    • getToolContext

      public Map<String,Object> getToolContext()
      Description copied from interface: ToolCallingChatOptions
      Get the configured tool context.
      Specified by:
      getToolContext in interface ToolCallingChatOptions
      Returns:
      the tool context map.
    • setToolContext

      public void setToolContext(Map<String,Object> toolContext)
      Description copied from interface: ToolCallingChatOptions
      Set the tool context values as map.
      Specified by:
      setToolContext in interface ToolCallingChatOptions
      Parameters:
      toolContext - as map
    • getTopK

      public Integer getTopK()
      Description copied from interface: ChatOptions
      Returns the top K to use for the chat.
      Specified by:
      getTopK in interface ChatOptions
      Returns:
      the top K to use for the chat
    • getOutputSchema

      public String getOutputSchema()
      Specified by:
      getOutputSchema in interface StructuredOutputChatOptions
    • setOutputSchema

      public void setOutputSchema(String outputSchema)
      Specified by:
      setOutputSchema in interface StructuredOutputChatOptions
    • builder

      public static OpenAiSdkChatOptions.Builder builder()
      Description copied from interface: ToolCallingChatOptions
      A builder to create a new ToolCallingChatOptions instance.
      Returns:
      Returns a new ChatOptions.Builder.
    • copy

      public OpenAiSdkChatOptions copy()
      Description copied from interface: ChatOptions
      Returns a copy of this ChatOptions.
      Specified by:
      copy in interface ChatOptions
      Returns:
      a copy of this ChatOptions
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object