Package org.springframework.ai.anthropic
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>
The
ChatModel implementation for the Anthropic service.- Since:
- 1.0.0
- Author:
- Christian Tzolov, luocongqiu, Mariusz Bernacki, Thomas Vitale, Claudio Silva Junior, Alexandros Pappas
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Integerstatic final Stringstatic final Doublefinal org.springframework.retry.support.RetryTemplateThe retry template used to retry the OpenAI API calls.Fields inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
functionCallbackRegister, functionCallbackResolver, IS_RUNTIME_CALL -
Constructor Summary
ConstructorsConstructorDescriptionAnthropicChatModel(AnthropicApi anthropicApi) Deprecated.AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions) Deprecated.AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackResolver functionCallbackResolver) Deprecated.AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackResolver functionCallbackResolver, List<FunctionCallback> toolFunctionCallbacks) Deprecated.AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackResolver functionCallbackResolver, List<FunctionCallback> toolFunctionCallbacks, io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicChatModel.Builderbuilder()internalCall(Prompt prompt, ChatResponse previousChatResponse) reactor.core.publisher.Flux<ChatResponse>internalStream(Prompt prompt, ChatResponse previousChatResponse) voidsetObservationConvention(ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<ChatResponse>Methods inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
buildToolCallConversation, executeFunctions, getFunctionCallbackRegister, handleToolCalls, isProxyToolCalls, isToolCall, isToolCall, resolveFunctionCallbacks, runtimeFunctionCallbackConfigurationsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Field Details
-
DEFAULT_MODEL_NAME
-
DEFAULT_MAX_TOKENS
-
DEFAULT_TEMPERATURE
-
retryTemplate
public final org.springframework.retry.support.RetryTemplate retryTemplateThe retry template used to retry the OpenAI API calls.
-
-
Constructor Details
-
AnthropicChatModel
Deprecated.Construct a newAnthropicChatModelinstance.- Parameters:
anthropicApi- the lower-level API for the Anthropic service.
-
AnthropicChatModel
@Deprecated public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions) Deprecated.Construct a newAnthropicChatModelinstance.- Parameters:
anthropicApi- the lower-level API for the Anthropic service.defaultOptions- the default options used for the chat completion requests.
-
AnthropicChatModel
@Deprecated public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate) Deprecated.Construct a newAnthropicChatModelinstance.- 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
@Deprecated public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackResolver functionCallbackResolver) Deprecated.Construct a newAnthropicChatModelinstance.- 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.functionCallbackResolver- the function callback resolver used to resolve the function by its name.
-
AnthropicChatModel
@Deprecated public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, FunctionCallbackResolver functionCallbackResolver, List<FunctionCallback> toolFunctionCallbacks) Deprecated.Construct a newAnthropicChatModelinstance.- 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.functionCallbackResolver- the function callback resolver used to resolve the function by its name.toolFunctionCallbacks- the tool function callbacks used to handle the tool calls.
-
AnthropicChatModel
@Deprecated public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate, @Nullable FunctionCallbackResolver functionCallbackResolver, @Nullable List<FunctionCallback> toolFunctionCallbacks, io.micrometer.observation.ObservationRegistry observationRegistry) Deprecated.Construct a newAnthropicChatModelinstance.- 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.functionCallbackResolver- the function callback resolver used to resolve the function by its name.toolFunctionCallbacks- the tool function callbacks used to handle the tool calls.
-
AnthropicChatModel
public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, ToolCallingManager toolCallingManager, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
-
-
Method Details
-
call
-
internalCall
-
stream
- Specified by:
streamin interfaceChatModel- Specified by:
streamin interfaceStreamingChatModel- Specified by:
streamin interfaceStreamingModel<Prompt,ChatResponse>
-
internalStream
public reactor.core.publisher.Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) -
getDefaultOptions
- Specified by:
getDefaultOptionsin interfaceChatModel
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-
builder
-
AnthropicChatModel.Builder.