Class AzureOpenAiChatClient
java.lang.Object
org.springframework.ai.model.function.AbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,com.azure.ai.openai.models.ChatCompletionsOptions,com.azure.ai.openai.models.ChatCompletions>
org.springframework.ai.azure.openai.AzureOpenAiChatClient
- All Implemented Interfaces:
ChatClient
,StreamingChatClient
,ModelClient<Prompt,
,ChatResponse> StreamingModelClient<Prompt,
ChatResponse>
public class AzureOpenAiChatClient
extends AbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,com.azure.ai.openai.models.ChatCompletionsOptions,com.azure.ai.openai.models.ChatCompletions>
implements ChatClient, StreamingChatClient
ChatClient
implementation for Microsoft Azure AI backed by
OpenAIClient
.- Author:
- Mark Pollack, Ueibin Kim, John Blum, Christian Tzolov
- See Also:
-
Field Summary
Fields inherited from class org.springframework.ai.model.function.AbstractFunctionCallSupport
functionCallbackContext, functionCallbackRegister, IS_RUNTIME_CALL
-
Constructor Summary
ConstructorDescriptionAzureOpenAiChatClient
(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient) AzureOpenAiChatClient
(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options) AzureOpenAiChatClient
(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options, FunctionCallbackContext functionCallbackContext) -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.protected com.azure.ai.openai.models.ChatCompletions
doChatCompletion
(com.azure.ai.openai.models.ChatCompletionsOptions request) protected com.azure.ai.openai.models.ChatCompletionsOptions
doCreateToolResponseRequest
(com.azure.ai.openai.models.ChatCompletionsOptions previousRequest, com.azure.ai.openai.models.ChatRequestMessage responseMessage, List<com.azure.ai.openai.models.ChatRequestMessage> conversationHistory) protected com.azure.ai.openai.models.ChatRequestMessage
doGetToolResponseMessage
(com.azure.ai.openai.models.ChatCompletions response) protected List
<com.azure.ai.openai.models.ChatRequestMessage> doGetUserMessages
(com.azure.ai.openai.models.ChatCompletionsOptions request) protected boolean
isToolFunctionCall
(com.azure.ai.openai.models.ChatCompletions chatCompletions) reactor.core.publisher.Flux
<ChatResponse> Executes a method call to the AI model.withDefaultOptions
(AzureOpenAiChatOptions defaultOptions) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class org.springframework.ai.model.function.AbstractFunctionCallSupport
callWithFunctionSupport, getFunctionCallbackRegister, handleFunctionCallbackConfigurations, handleFunctionCallOrReturn, resolveFunctionCallbacks
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
Methods inherited from interface org.springframework.ai.chat.StreamingChatClient
stream
-
Constructor Details
-
AzureOpenAiChatClient
public AzureOpenAiChatClient(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient) -
AzureOpenAiChatClient
public AzureOpenAiChatClient(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options) -
AzureOpenAiChatClient
public AzureOpenAiChatClient(com.azure.ai.openai.OpenAIClient microsoftOpenAiClient, AzureOpenAiChatOptions options, FunctionCallbackContext functionCallbackContext)
-
-
Method Details
-
withDefaultOptions
@Deprecated(forRemoval=true, since="0.8.0") public AzureOpenAiChatClient withDefaultOptions(AzureOpenAiChatOptions defaultOptions) Deprecated, for removal: This API element is subject to removal in a future version.since 0.8.0, useAzureOpenAiChatClient(OpenAIClient, AzureOpenAiChatOptions)
instead. -
getDefaultOptions
-
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
-
doCreateToolResponseRequest
protected com.azure.ai.openai.models.ChatCompletionsOptions doCreateToolResponseRequest(com.azure.ai.openai.models.ChatCompletionsOptions previousRequest, com.azure.ai.openai.models.ChatRequestMessage responseMessage, List<com.azure.ai.openai.models.ChatRequestMessage> conversationHistory) - Specified by:
doCreateToolResponseRequest
in classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,
com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
doGetUserMessages
protected List<com.azure.ai.openai.models.ChatRequestMessage> doGetUserMessages(com.azure.ai.openai.models.ChatCompletionsOptions request) - Specified by:
doGetUserMessages
in classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,
com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
doGetToolResponseMessage
protected com.azure.ai.openai.models.ChatRequestMessage doGetToolResponseMessage(com.azure.ai.openai.models.ChatCompletions response) - Specified by:
doGetToolResponseMessage
in classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,
com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
doChatCompletion
protected com.azure.ai.openai.models.ChatCompletions doChatCompletion(com.azure.ai.openai.models.ChatCompletionsOptions request) - Specified by:
doChatCompletion
in classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,
com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
isToolFunctionCall
protected boolean isToolFunctionCall(com.azure.ai.openai.models.ChatCompletions chatCompletions) - Specified by:
isToolFunctionCall
in classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,
com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
AzureOpenAiChatClient(OpenAIClient, AzureOpenAiChatOptions)
instead.