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:
-
ChatClientOpenAIClient
-
Field Summary
Fields inherited from class org.springframework.ai.model.function.AbstractFunctionCallSupport
functionCallbackContext, functionCallbackRegister, IS_RUNTIME_CALL -
Constructor Summary
ConstructorsConstructorDescriptionAzureOpenAiChatClient(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.ChatCompletionsdoChatCompletion(com.azure.ai.openai.models.ChatCompletionsOptions request) protected com.azure.ai.openai.models.ChatCompletionsOptionsdoCreateToolResponseRequest(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.ChatRequestMessagedoGetToolResponseMessage(com.azure.ai.openai.models.ChatCompletions response) protected List<com.azure.ai.openai.models.ChatRequestMessage>doGetUserMessages(com.azure.ai.openai.models.ChatCompletionsOptions request) protected booleanisToolFunctionCall(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, resolveFunctionCallbacksMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.ChatClient
callMethods 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:ModelClientExecutes a method call to the AI model.- Specified by:
callin interfaceChatClient- Specified by:
callin 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:StreamingModelClientExecutes a method call to the AI model.- Specified by:
streamin interfaceStreamingChatClient- Specified by:
streamin 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:
doCreateToolResponseRequestin 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:
doGetUserMessagesin 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:
doGetToolResponseMessagein 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:
doChatCompletionin 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:
isToolFunctionCallin classAbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,com.azure.ai.openai.models.ChatCompletionsOptions, com.azure.ai.openai.models.ChatCompletions>
-
AzureOpenAiChatClient(OpenAIClient, AzureOpenAiChatOptions)instead.