Class AzureOpenAiChatModel

java.lang.Object
org.springframework.ai.azure.openai.AzureOpenAiChatModel
All Implemented Interfaces:
org.springframework.ai.chat.model.ChatModel, org.springframework.ai.chat.model.StreamingChatModel, org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>, org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>

public class AzureOpenAiChatModel extends Object implements org.springframework.ai.chat.model.ChatModel
ChatModel implementation for Microsoft Azure AI backed by OpenAIClient.
Since:
1.0.0
Author:
Mark Pollack, Ueibin Kim, John Blum, Christian Tzolov, Grogdunn, Benoit Moussaud, Thomas Vitale, luocongqiu, timostark, Soby Chacko, Jihoon Kim, Ilayaperumal Gopinathan, Alexandros Pappas, Berjan Jonker, Andres da Silva Santos, Bart Veenstra
See Also:
  • ChatModel
  • OpenAIClient
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Builder to construct AzureOpenAiChatModel.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AzureOpenAiChatModel(com.azure.ai.openai.OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, io.micrometer.observation.ObservationRegistry observationRegistry)
     
    AzureOpenAiChatModel(com.azure.ai.openai.OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    org.springframework.ai.chat.model.ChatResponse
    call(org.springframework.ai.chat.prompt.Prompt prompt)
     
    static org.springframework.ai.chat.metadata.ChatResponseMetadata
    from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata)
     
    static org.springframework.ai.chat.metadata.ChatResponseMetadata
    from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata, com.azure.ai.openai.models.CompletionsUsage usage)
     
    static org.springframework.ai.chat.metadata.ChatResponseMetadata
    from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata, org.springframework.ai.chat.metadata.Usage usage)
     
    static org.springframework.ai.chat.metadata.ChatResponseMetadata
    from(org.springframework.ai.chat.model.ChatResponse chatResponse, org.springframework.ai.chat.metadata.Usage usage)
     
     
    org.springframework.ai.chat.model.ChatResponse
    internalCall(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
     
    reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>
    internalStream(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
     
    void
    setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)
    Use the provided convention for reporting observation data
    reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse>
    stream(org.springframework.ai.chat.prompt.Prompt prompt)
     

    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.model.ChatModel

    call, call

    Methods inherited from interface org.springframework.ai.chat.model.StreamingChatModel

    stream, stream
  • Constructor Details

    • AzureOpenAiChatModel

      public AzureOpenAiChatModel(com.azure.ai.openai.OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, io.micrometer.observation.ObservationRegistry observationRegistry)
    • AzureOpenAiChatModel

      public AzureOpenAiChatModel(com.azure.ai.openai.OpenAIClientBuilder openAIClientBuilder, AzureOpenAiChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate)
  • Method Details

    • from

      public static org.springframework.ai.chat.metadata.ChatResponseMetadata from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata, org.springframework.ai.chat.metadata.Usage usage)
    • from

      public static org.springframework.ai.chat.metadata.ChatResponseMetadata from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata)
    • from

      public static org.springframework.ai.chat.metadata.ChatResponseMetadata from(com.azure.ai.openai.models.ChatCompletions chatCompletions, org.springframework.ai.chat.metadata.PromptMetadata promptFilterMetadata, com.azure.ai.openai.models.CompletionsUsage usage)
    • from

      public static org.springframework.ai.chat.metadata.ChatResponseMetadata from(org.springframework.ai.chat.model.ChatResponse chatResponse, org.springframework.ai.chat.metadata.Usage usage)
    • getDefaultOptions

      public AzureOpenAiChatOptions getDefaultOptions()
      Specified by:
      getDefaultOptions in interface org.springframework.ai.chat.model.ChatModel
    • call

      public org.springframework.ai.chat.model.ChatResponse call(org.springframework.ai.chat.prompt.Prompt prompt)
      Specified by:
      call in interface org.springframework.ai.chat.model.ChatModel
      Specified by:
      call in interface org.springframework.ai.model.Model<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>
    • internalCall

      public org.springframework.ai.chat.model.ChatResponse internalCall(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
    • stream

      public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> stream(org.springframework.ai.chat.prompt.Prompt prompt)
      Specified by:
      stream in interface org.springframework.ai.chat.model.ChatModel
      Specified by:
      stream in interface org.springframework.ai.chat.model.StreamingChatModel
      Specified by:
      stream in interface org.springframework.ai.model.StreamingModel<org.springframework.ai.chat.prompt.Prompt,org.springframework.ai.chat.model.ChatResponse>
    • internalStream

      public reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> internalStream(org.springframework.ai.chat.prompt.Prompt prompt, org.springframework.ai.chat.model.ChatResponse previousChatResponse)
    • setObservationConvention

      public void setObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention)
      Use the provided convention for reporting observation data
      Parameters:
      observationConvention - The provided convention
    • builder

      public static AzureOpenAiChatModel.Builder builder()