Package org.springframework.ai.openai
Class OpenAiChatClient
java.lang.Object
org.springframework.ai.openai.OpenAiChatClient
- All Implemented Interfaces:
ChatClient
,StreamingChatClient
,ModelClient<Prompt,
,ChatResponse> StreamingModelClient<Prompt,
ChatResponse>
ChatClient
implementation for OpenAI backed by OpenAiApi
.- Author:
- Mark Pollack, Christian Tzolov, Ueibin Kim, John Blum, Josh Long, Jemin Huh
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal org.springframework.retry.support.RetryTemplate
The retry template used to retry the OpenAI API calls. -
Constructor Summary
ConstructorDescriptionOpenAiChatClient
(OpenAiApi openAiApi) OpenAiChatClient
(OpenAiApi openAiApi, OpenAiChatOptions options) OpenAiChatClient
(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackContext functionCallbackContext) -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.reactor.core.publisher.Flux
<ChatResponse> Executes a method call to the AI model.withDefaultOptions
(OpenAiChatOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.chat.ChatClient
call
-
Field Details
-
retryTemplate
public final org.springframework.retry.support.RetryTemplate retryTemplateThe retry template used to retry the OpenAI API calls.
-
-
Constructor Details
-
OpenAiChatClient
-
OpenAiChatClient
-
OpenAiChatClient
public OpenAiChatClient(OpenAiApi openAiApi, OpenAiChatOptions options, FunctionCallbackContext functionCallbackContext)
-
-
Method Details
-
withDefaultOptions
@Deprecated(since="0.8.0", forRemoval=true) public OpenAiChatClient withDefaultOptions(OpenAiChatOptions options) Deprecated, for removal: This API element is subject to removal in a future version.since 0.8.0, use theOpenAiChatClient(OpenAiApi, OpenAiChatOptions)
constructor instead. -
call
Description copied from interface:ModelClient
Executes a method call to the AI model.- Specified by:
call
in interfaceChatClient
- Specified by:
call
in interfaceModelClient<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
stream
Description copied from interface:StreamingModelClient
Executes a method call to the AI model.- Specified by:
stream
in interfaceStreamingChatClient
- Specified by:
stream
in interfaceStreamingModelClient<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
OpenAiChatClient(OpenAiApi, OpenAiChatOptions)
constructor instead.