Class AnthropicChatModel

java.lang.Object
org.springframework.ai.chat.model.AbstractToolCallSupport
org.springframework.ai.anthropic.AnthropicChatModel
All Implemented Interfaces:
ChatModel, StreamingChatModel, Model<Prompt,ChatResponse>, StreamingModel<Prompt,ChatResponse>

public class AnthropicChatModel extends AbstractToolCallSupport implements ChatModel
The ChatModel implementation for the Anthropic service.
Since:
1.0.0
Author:
Christian Tzolov, luocongqiu, Mariusz Bernacki, Thomas Vitale, Claudio Silva Junior
  • Field Details

    • DEFAULT_MODEL_NAME

      public static final String DEFAULT_MODEL_NAME
    • DEFAULT_MAX_TOKENS

      public static final Integer DEFAULT_MAX_TOKENS
    • DEFAULT_TEMPERATURE

      public static final Double DEFAULT_TEMPERATURE
    • retryTemplate

      public final org.springframework.retry.support.RetryTemplate retryTemplate
      The retry template used to retry the OpenAI API calls.
  • Constructor Details

    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
      defaultOptions - the default options used for the chat completion requests.
    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
      defaultOptions - the default options used for the chat completion requests.
      retryTemplate - the retry template used to retry the Anthropic API calls.
    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackContext functionCallbackContext)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
      defaultOptions - the default options used for the chat completion requests.
      retryTemplate - the retry template used to retry the Anthropic API calls.
      functionCallbackContext - the function callback context used to store the state of the function calls.
    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
      defaultOptions - the default options used for the chat completion requests.
      retryTemplate - the retry template used to retry the Anthropic API calls.
      functionCallbackContext - the function callback context used to store the state of the function calls.
      toolFunctionCallbacks - the tool function callbacks used to handle the tool calls.
    • AnthropicChatModel

      public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks, io.micrometer.observation.ObservationRegistry observationRegistry)
      Construct a new AnthropicChatModel instance.
      Parameters:
      anthropicApi - the lower-level API for the Anthropic service.
      defaultOptions - the default options used for the chat completion requests.
      retryTemplate - the retry template used to retry the Anthropic API calls.
      functionCallbackContext - the function callback context used to store the state of the function calls.
      toolFunctionCallbacks - the tool function callbacks used to handle the tool calls.
  • Method Details