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:
  • 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.
    • getDefaultOptions

      public AzureOpenAiChatOptions getDefaultOptions()
    • call

      public ChatResponse call(Prompt prompt)
      Description copied from interface: ModelClient
      Executes a method call to the AI model.
      Specified by:
      call in interface ChatClient
      Specified by:
      call in interface ModelClient<Prompt,ChatResponse>
      Parameters:
      prompt - the request object to be sent to the AI model
      Returns:
      the response from the AI model
    • stream

      public reactor.core.publisher.Flux<ChatResponse> stream(Prompt prompt)
      Description copied from interface: StreamingModelClient
      Executes a method call to the AI model.
      Specified by:
      stream in interface StreamingChatClient
      Specified by:
      stream in interface StreamingModelClient<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 class AbstractFunctionCallSupport<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 class AbstractFunctionCallSupport<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 class AbstractFunctionCallSupport<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 class AbstractFunctionCallSupport<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 class AbstractFunctionCallSupport<com.azure.ai.openai.models.ChatRequestMessage,com.azure.ai.openai.models.ChatCompletionsOptions,com.azure.ai.openai.models.ChatCompletions>