Class AnthropicChatModel
java.lang.Object
org.springframework.ai.anthropic.AnthropicChatModel
- 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 AnthropicChatModel
extends Object
implements org.springframework.ai.chat.model.ChatModel
The
ChatModel implementation for the Anthropic service.- Since:
- 1.0.0
- Author:
- Christian Tzolov, luocongqiu, Mariusz Bernacki, Thomas Vitale, Claudio Silva Junior, Alexandros Pappas, Jonghoon Park, Soby Chacko, Austin Dase
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate) -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicChatModel.Builderbuilder()org.springframework.ai.chat.model.ChatResponsecall(org.springframework.ai.chat.prompt.Prompt prompt) org.springframework.ai.chat.prompt.ChatOptionsorg.springframework.ai.chat.model.ChatResponseinternalCall(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) voidsetObservationConvention(org.springframework.ai.chat.observation.ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> stream(org.springframework.ai.chat.prompt.Prompt prompt) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.model.ChatModel
call, callMethods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Field Details
-
DEFAULT_MODEL_NAME
-
DEFAULT_MAX_TOKENS
-
retryTemplate
public final org.springframework.core.retry.RetryTemplate retryTemplateThe retry template used to retry the OpenAI API calls.
-
-
Constructor Details
-
AnthropicChatModel
public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) -
AnthropicChatModel
public AnthropicChatModel(AnthropicApi anthropicApi, AnthropicChatOptions defaultOptions, org.springframework.ai.model.tool.ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry, org.springframework.ai.model.tool.ToolExecutionEligibilityPredicate toolExecutionEligibilityPredicate)
-
-
Method Details
-
call
public org.springframework.ai.chat.model.ChatResponse call(org.springframework.ai.chat.prompt.Prompt prompt) - Specified by:
callin interfaceorg.springframework.ai.chat.model.ChatModel- Specified by:
callin interfaceorg.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:
streamin interfaceorg.springframework.ai.chat.model.ChatModel- Specified by:
streamin interfaceorg.springframework.ai.chat.model.StreamingChatModel- Specified by:
streamin interfaceorg.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) -
getDefaultOptions
public org.springframework.ai.chat.prompt.ChatOptions getDefaultOptions()- Specified by:
getDefaultOptionsin interfaceorg.springframework.ai.chat.model.ChatModel
-
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
-