Class OpenAiChatOptions

java.lang.Object
org.springframework.ai.openai.OpenAiChatOptions
All Implemented Interfaces:
ChatOptions, FunctionCallingOptions, ModelOptions

public class OpenAiChatOptions extends Object implements FunctionCallingOptions
Options for the OpenAI Chat API.
Since:
0.8.0
Author:
Christian Tzolov, Mariusz Bernacki, Thomas Vitale
  • Constructor Details

    • OpenAiChatOptions

      public OpenAiChatOptions()
  • Method Details

    • builder

      public static OpenAiChatOptions.Builder builder()
      Returns:
      Returns FunctionCallingOptionsBuilder to create a new instance of FunctionCallingOptions.
    • fromOptions

      public static OpenAiChatOptions fromOptions(OpenAiChatOptions fromOptions)
    • getStreamUsage

      public Boolean getStreamUsage()
    • setStreamUsage

      public void setStreamUsage(Boolean enableStreamUsage)
    • getModel

      public String getModel()
      Description copied from interface: ChatOptions
      Returns the model to use for the chat.
      Specified by:
      getModel in interface ChatOptions
      Returns:
      the model to use for the chat
    • setModel

      public void setModel(String model)
    • getFrequencyPenalty

      public Double getFrequencyPenalty()
      Description copied from interface: ChatOptions
      Returns the frequency penalty to use for the chat.
      Specified by:
      getFrequencyPenalty in interface ChatOptions
      Returns:
      the frequency penalty to use for the chat
    • setFrequencyPenalty

      public void setFrequencyPenalty(Double frequencyPenalty)
    • getLogitBias

      public Map<String,Integer> getLogitBias()
    • setLogitBias

      public void setLogitBias(Map<String,Integer> logitBias)
    • getLogprobs

      public Boolean getLogprobs()
    • setLogprobs

      public void setLogprobs(Boolean logprobs)
    • getTopLogprobs

      public Integer getTopLogprobs()
    • setTopLogprobs

      public void setTopLogprobs(Integer topLogprobs)
    • 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)
    • getMaxCompletionTokens

      public Integer getMaxCompletionTokens()
    • setMaxCompletionTokens

      public void setMaxCompletionTokens(Integer maxCompletionTokens)
    • getN

      public Integer getN()
    • setN

      public void setN(Integer n)
    • 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)
    • getResponseFormat

      public ResponseFormat getResponseFormat()
    • setResponseFormat

      public void setResponseFormat(ResponseFormat responseFormat)
    • getStreamOptions

    • setStreamOptions

      public void setStreamOptions(OpenAiApi.ChatCompletionRequest.StreamOptions streamOptions)
    • getSeed

      public Integer getSeed()
    • setSeed

      public void setSeed(Integer seed)
    • 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)
    • getStop

      public List<String> getStop()
    • setStop

      public void setStop(List<String> stop)
    • 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)
    • 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)
    • getTools

      public List<OpenAiApi.FunctionTool> getTools()
    • setTools

      public void setTools(List<OpenAiApi.FunctionTool> tools)
    • getToolChoice

      public String getToolChoice()
    • setToolChoice

      public void setToolChoice(String toolChoice)
    • getProxyToolCalls

      public Boolean getProxyToolCalls()
      Specified by:
      getProxyToolCalls in interface FunctionCallingOptions
    • setProxyToolCalls

      public void setProxyToolCalls(Boolean proxyToolCalls)
      Specified by:
      setProxyToolCalls in interface FunctionCallingOptions
    • getUser

      public String getUser()
    • setUser

      public void setUser(String user)
    • getParallelToolCalls

      public Boolean getParallelToolCalls()
    • setParallelToolCalls

      public void setParallelToolCalls(Boolean parallelToolCalls)
    • getFunctionCallbacks

      public List<FunctionCallback> getFunctionCallbacks()
      Description copied from interface: FunctionCallingOptions
      Function Callbacks to be registered with the ChatModel. For Prompt Options the functionCallbacks are automatically enabled for the duration of the prompt execution. For Default Options the FunctionCallbacks are registered but disabled by default. You have to use "functions" property to list the function names from the ChatModel registry to be used in the chat completion requests.
      Specified by:
      getFunctionCallbacks in interface FunctionCallingOptions
      Returns:
      Return the Function Callbacks to be registered with the ChatModel.
    • setFunctionCallbacks

      public void setFunctionCallbacks(List<FunctionCallback> functionCallbacks)
      Description copied from interface: FunctionCallingOptions
      Set the Function Callbacks to be registered with the ChatModel.
      Specified by:
      setFunctionCallbacks in interface FunctionCallingOptions
      Parameters:
      functionCallbacks - the Function Callbacks to be registered with the ChatModel.
    • getFunctions

      public Set<String> getFunctions()
      Specified by:
      getFunctions in interface FunctionCallingOptions
      Returns:
      Set of function names from the ChatModel registry to be used in the next chat completion requests.
    • setFunctions

      public void setFunctions(Set<String> functionNames)
      Description copied from interface: FunctionCallingOptions
      Set the list of function names from the ChatModel registry to be used in the next chat completion requests.
      Specified by:
      setFunctions in interface FunctionCallingOptions
      Parameters:
      functionNames - the list of function names from the ChatModel registry to be used in the next chat completion requests.
    • getHttpHeaders

      public Map<String,String> getHttpHeaders()
    • setHttpHeaders

      public void setHttpHeaders(Map<String,String> httpHeaders)
    • 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
    • getToolContext

      public Map<String,Object> getToolContext()
      Specified by:
      getToolContext in interface FunctionCallingOptions
    • setToolContext

      public void setToolContext(Map<String,Object> toolContext)
      Specified by:
      setToolContext in interface FunctionCallingOptions
    • copy

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

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

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

      public String toString()
      Overrides:
      toString in class Object