Package org.springframework.ai.openai
Class OpenAiChatOptions
java.lang.Object
org.springframework.ai.openai.OpenAiChatOptions
- All Implemented Interfaces:
ChatOptions
,ModelOptions
,ToolCallingChatOptions
Options for the OpenAI Chat API.
- Since:
- 0.8.0
- Author:
- Christian Tzolov, Mariusz Bernacki, Thomas Vitale, Ilayaperumal Gopinathan
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface org.springframework.ai.model.tool.ToolCallingChatOptions
DEFAULT_TOOL_EXECUTION_ENABLED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiChatOptions.Builder
builder()
A builder to create a newToolCallingChatOptions
instance.copy()
Returns a copy of thisChatOptions
.boolean
static OpenAiChatOptions
fromOptions
(OpenAiChatOptions fromOptions) Returns the frequency penalty to use for the chat.Whether theChatModel
is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.Returns the maximum number of tokens to use for the chat.getModel()
Returns the model to use for the chat.getN()
Returns the presence penalty to use for the chat.getSeed()
getStop()
Returns the stop sequences to use for the chat.getStore()
Returns the temperature to use for the chat.ToolCallbacks to be registered with the ChatModel.Get the configured tool context.Names of the tools to register with the ChatModel.getTools()
getTopK()
Returns the top K to use for the chat.getTopP()
Returns the top P to use for the chat.getUser()
int
hashCode()
void
setFrequencyPenalty
(Double frequencyPenalty) void
setHttpHeaders
(Map<String, String> httpHeaders) void
setInternalToolExecutionEnabled
(Boolean internalToolExecutionEnabled) Set whether theChatModel
is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.void
setLogitBias
(Map<String, Integer> logitBias) void
setLogprobs
(Boolean logprobs) void
setMaxCompletionTokens
(Integer maxCompletionTokens) void
setMaxTokens
(Integer maxTokens) void
setMetadata
(Map<String, String> metadata) void
void
void
void
setOutputModalities
(List<String> modalities) void
setParallelToolCalls
(Boolean parallelToolCalls) void
setPresencePenalty
(Double presencePenalty) void
setReasoningEffort
(String reasoningEffort) void
setResponseFormat
(ResponseFormat responseFormat) void
void
void
setStopSequences
(List<String> stopSequences) void
void
setStreamOptions
(OpenAiApi.ChatCompletionRequest.StreamOptions streamOptions) void
setStreamUsage
(Boolean enableStreamUsage) void
setTemperature
(Double temperature) void
setToolCallbacks
(List<ToolCallback> toolCallbacks) Set the ToolCallbacks to be registered with the ChatModel.void
setToolChoice
(Object toolChoice) void
setToolContext
(Map<String, Object> toolContext) Set the tool context values as map.void
setToolNames
(Set<String> toolNames) Set the names of the tools to register with the ChatModel.void
setTools
(List<OpenAiApi.FunctionTool> tools) void
setTopLogprobs
(Integer topLogprobs) void
void
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.ai.model.tool.ToolCallingChatOptions
isInternalToolExecutionEnabled
-
Constructor Details
-
OpenAiChatOptions
public OpenAiChatOptions()
-
-
Method Details
-
builder
Description copied from interface:ToolCallingChatOptions
A builder to create a newToolCallingChatOptions
instance.- Returns:
- Returns a new
ChatOptions.Builder
.
-
fromOptions
-
getStreamUsage
-
setStreamUsage
-
getModel
Description copied from interface:ChatOptions
Returns the model to use for the chat.- Specified by:
getModel
in interfaceChatOptions
- Returns:
- the model to use for the chat
-
setModel
-
getFrequencyPenalty
Description copied from interface:ChatOptions
Returns the frequency penalty to use for the chat.- Specified by:
getFrequencyPenalty
in interfaceChatOptions
- Returns:
- the frequency penalty to use for the chat
-
setFrequencyPenalty
-
getLogitBias
-
setLogitBias
-
getLogprobs
-
setLogprobs
-
getTopLogprobs
-
setTopLogprobs
-
getMaxTokens
Description copied from interface:ChatOptions
Returns the maximum number of tokens to use for the chat.- Specified by:
getMaxTokens
in interfaceChatOptions
- Returns:
- the maximum number of tokens to use for the chat
-
setMaxTokens
-
getMaxCompletionTokens
-
setMaxCompletionTokens
-
getN
-
setN
-
getOutputModalities
-
setOutputModalities
-
getOutputAudio
-
setOutputAudio
-
getPresencePenalty
Description copied from interface:ChatOptions
Returns the presence penalty to use for the chat.- Specified by:
getPresencePenalty
in interfaceChatOptions
- Returns:
- the presence penalty to use for the chat
-
setPresencePenalty
-
getResponseFormat
-
setResponseFormat
-
getStreamOptions
-
setStreamOptions
-
getSeed
-
setSeed
-
getStopSequences
Description copied from interface:ChatOptions
Returns the stop sequences to use for the chat.- Specified by:
getStopSequences
in interfaceChatOptions
- Returns:
- the stop sequences to use for the chat
-
setStopSequences
-
getStop
-
setStop
-
getTemperature
Description copied from interface:ChatOptions
Returns the temperature to use for the chat.- Specified by:
getTemperature
in interfaceChatOptions
- Returns:
- the temperature to use for the chat
-
setTemperature
-
getTopP
Description copied from interface:ChatOptions
Returns the top P to use for the chat.- Specified by:
getTopP
in interfaceChatOptions
- Returns:
- the top P to use for the chat
-
setTopP
-
getTools
-
setTools
-
getToolChoice
-
setToolChoice
-
getUser
-
setUser
-
getParallelToolCalls
-
setParallelToolCalls
-
getToolCallbacks
Description copied from interface:ToolCallingChatOptions
ToolCallbacks to be registered with the ChatModel.- Specified by:
getToolCallbacks
in interfaceToolCallingChatOptions
-
setToolCallbacks
Description copied from interface:ToolCallingChatOptions
Set the ToolCallbacks to be registered with the ChatModel.- Specified by:
setToolCallbacks
in interfaceToolCallingChatOptions
-
getToolNames
Description copied from interface:ToolCallingChatOptions
Names of the tools to register with the ChatModel.- Specified by:
getToolNames
in interfaceToolCallingChatOptions
-
setToolNames
Description copied from interface:ToolCallingChatOptions
Set the names of the tools to register with the ChatModel.- Specified by:
setToolNames
in interfaceToolCallingChatOptions
-
getInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptions
Whether theChatModel
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 interfaceToolCallingChatOptions
-
setInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptions
Set whether theChatModel
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 interfaceToolCallingChatOptions
-
getHttpHeaders
-
setHttpHeaders
-
getTopK
Description copied from interface:ChatOptions
Returns the top K to use for the chat.- Specified by:
getTopK
in interfaceChatOptions
- Returns:
- the top K to use for the chat
-
getToolContext
Description copied from interface:ToolCallingChatOptions
Get the configured tool context.- Specified by:
getToolContext
in interfaceToolCallingChatOptions
- Returns:
- the tool context map.
-
setToolContext
Description copied from interface:ToolCallingChatOptions
Set the tool context values as map.- Specified by:
setToolContext
in interfaceToolCallingChatOptions
- Parameters:
toolContext
- as map
-
getStore
-
setStore
-
getMetadata
-
setMetadata
-
getReasoningEffort
-
setReasoningEffort
-
copy
Description copied from interface:ChatOptions
Returns a copy of thisChatOptions
.- Specified by:
copy
in interfaceChatOptions
- Returns:
- a copy of this
ChatOptions
-
hashCode
public int hashCode() -
equals
-
toString
-