Package org.springframework.ai.openai
Class OpenAiChatModel
java.lang.Object
org.springframework.ai.chat.model.AbstractToolCallSupport
org.springframework.ai.openai.OpenAiChatModel
- All Implemented Interfaces:
ChatModel,StreamingChatModel,Model<Prompt,,ChatResponse> StreamingModel<Prompt,ChatResponse>
- Author:
- Mark Pollack, Christian Tzolov, Ueibin Kim, John Blum, Josh Long, Jemin Huh, Grogdunn, Hyunjoon Choi, Mariusz Bernacki, luocongqiu, Thomas Vitale, Ilayaperumal Gopinathan, Alexandros Pappas
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
functionCallbackRegister, functionCallbackResolver, IS_RUNTIME_CALL -
Constructor Summary
ConstructorsConstructorDescriptionOpenAiChatModel(OpenAiApi openAiApi) Deprecated.Use OpenAiChatModel.Builder.OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options) Deprecated.Use OpenAiChatModel.Builder.OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackResolver functionCallbackResolver, List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.Use OpenAiChatModel.Builder.OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackResolver functionCallbackResolver, List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.Use OpenAiChatModel.Builder or OpenAiChatModel(OpenAiApi, OpenAiChatOptions, ToolCallingManager, RetryTemplate, ObservationRegistry).OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackResolver functionCallbackResolver, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.Use OpenAiChatModel.Builder.OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions defaultOptions, ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenAiChatModel.Builderbuilder()Executes a method call to the AI model.internalCall(Prompt prompt, ChatResponse previousChatResponse) reactor.core.publisher.Flux<ChatResponse>internalStream(Prompt prompt, ChatResponse previousChatResponse) voidsetObservationConvention(ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<ChatResponse>Executes a method call to the AI model.toString()Methods inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
buildToolCallConversation, executeFunctions, getFunctionCallbackRegister, handleToolCalls, isProxyToolCalls, isToolCall, isToolCall, resolveFunctionCallbacks, runtimeFunctionCallbackConfigurationsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Constructor Details
-
OpenAiChatModel
Deprecated.Use OpenAiChatModel.Builder.Creates an instance of the OpenAiChatModel.- Parameters:
openAiApi- The OpenAiApi instance to be used for interacting with the OpenAI Chat API.- Throws:
IllegalArgumentException- if openAiApi is null
-
OpenAiChatModel
Deprecated.Use OpenAiChatModel.Builder.Initializes an instance of the OpenAiChatModel.- Parameters:
openAiApi- The OpenAiApi instance to be used for interacting with the OpenAI Chat API.options- The OpenAiChatOptions to configure the chat model.
-
OpenAiChatModel
@Deprecated public OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, @Nullable FunctionCallbackResolver functionCallbackResolver, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.Use OpenAiChatModel.Builder.Initializes a new instance of the OpenAiChatModel.- Parameters:
openAiApi- The OpenAiApi instance to be used for interacting with the OpenAI Chat API.options- The OpenAiChatOptions to configure the chat model.functionCallbackResolver- The function callback resolver.retryTemplate- The retry template.
-
OpenAiChatModel
@Deprecated public OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, @Nullable FunctionCallbackResolver functionCallbackResolver, @Nullable List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.Use OpenAiChatModel.Builder.Initializes a new instance of the OpenAiChatModel.- Parameters:
openAiApi- The OpenAiApi instance to be used for interacting with the OpenAI Chat API.options- The OpenAiChatOptions to configure the chat model.functionCallbackResolver- The function callback resolver.toolFunctionCallbacks- The tool function callbacks.retryTemplate- The retry template.
-
OpenAiChatModel
@Deprecated public OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions options, @Nullable FunctionCallbackResolver functionCallbackResolver, @Nullable List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.Use OpenAiChatModel.Builder or OpenAiChatModel(OpenAiApi, OpenAiChatOptions, ToolCallingManager, RetryTemplate, ObservationRegistry).Initializes a new instance of the OpenAiChatModel.- Parameters:
openAiApi- The OpenAiApi instance to be used for interacting with the OpenAI Chat API.options- The OpenAiChatOptions to configure the chat model.functionCallbackResolver- The function callback resolver.toolFunctionCallbacks- The tool function callbacks.retryTemplate- The retry template.observationRegistry- The ObservationRegistry used for instrumentation.
-
OpenAiChatModel
public OpenAiChatModel(OpenAiApi openAiApi, OpenAiChatOptions defaultOptions, ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
-
-
Method Details
-
call
Description copied from interface:ModelExecutes a method call to the AI model. -
internalCall
-
stream
Description copied from interface:StreamingModelExecutes a method call to the AI model.- Specified by:
streamin interfaceChatModel- Specified by:
streamin interfaceStreamingChatModel- Specified by:
streamin interfaceStreamingModel<Prompt,ChatResponse> - Parameters:
prompt- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
internalStream
public reactor.core.publisher.Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) -
getDefaultOptions
- Specified by:
getDefaultOptionsin interfaceChatModel
-
toString
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-
builder
-