Class AnthropicChatBedrockApi
java.lang.Object
org.springframework.ai.bedrock.api.AbstractBedrockApi<AnthropicChatBedrockApi.AnthropicChatRequest,AnthropicChatBedrockApi.AnthropicChatResponse,AnthropicChatBedrockApi.AnthropicChatResponse>
org.springframework.ai.bedrock.anthropic.api.AnthropicChatBedrockApi
public class AnthropicChatBedrockApi
extends AbstractBedrockApi<AnthropicChatBedrockApi.AnthropicChatRequest,AnthropicChatBedrockApi.AnthropicChatResponse,AnthropicChatBedrockApi.AnthropicChatResponse>
Anthropic Chat API.
- Since:
- 0.8.0
- Author:
- Christian Tzolov, Thomas Vitale, Wei Jiang
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Anthropic models version.static final record
AnthropicChatRequest encapsulates the request parameters for the Anthropic chat model.static final record
AnthropicChatResponse encapsulates the response parameters for the Anthropic chat model.Nested classes/interfaces inherited from class org.springframework.ai.bedrock.api.AbstractBedrockApi
AbstractBedrockApi.AmazonBedrockInvocationMetrics
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default version of the Anthropic chat model.static final String
Fields inherited from class org.springframework.ai.bedrock.api.AbstractBedrockApi
DEFAULT_EMIT_FAILURE_HANDLER
-
Constructor Summary
ConstructorDescriptionAnthropicChatBedrockApi
(String modelId, String region) Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.AnthropicChatBedrockApi
(String modelId, String region, Duration timeout) Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.AnthropicChatBedrockApi
(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, String region, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.AnthropicChatBedrockApi
(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, String region, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Duration timeout) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.AnthropicChatBedrockApi
(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, software.amazon.awssdk.regions.Region region, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Duration timeout) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper. -
Method Summary
Modifier and TypeMethodDescriptionchatCompletion
(AnthropicChatBedrockApi.AnthropicChatRequest anthropicRequest) Chat completion invocation.reactor.core.publisher.Flux<AnthropicChatBedrockApi.AnthropicChatResponse>
chatCompletionStream
(AnthropicChatBedrockApi.AnthropicChatRequest anthropicRequest) Chat completion invocation with streaming response.Methods inherited from class org.springframework.ai.bedrock.api.AbstractBedrockApi
embedding, getModelId, getRegion, internalInvocation, internalInvocationStream
-
Field Details
-
PROMPT_TEMPLATE
- See Also:
-
DEFAULT_ANTHROPIC_VERSION
Default version of the Anthropic chat model.- See Also:
-
-
Constructor Details
-
AnthropicChatBedrockApi
Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.- Parameters:
modelId
- The model id to use. See theAnthropicChatBedrockApi.AnthropicChatModel
for the supported models.region
- The AWS region to use.
-
AnthropicChatBedrockApi
Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.- Parameters:
modelId
- The model id to use. See theAnthropicChatBedrockApi.AnthropicChatModel
for the supported models.region
- The AWS region to use.timeout
- The timeout to use.
-
AnthropicChatBedrockApi
public AnthropicChatBedrockApi(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, String region, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.- Parameters:
modelId
- The model id to use. See theAnthropicChatBedrockApi.AnthropicChatModel
for the supported models.credentialsProvider
- The credentials provider to connect to AWS.region
- The AWS region to use.objectMapper
- The object mapper to use for JSON serialization and deserialization.
-
AnthropicChatBedrockApi
public AnthropicChatBedrockApi(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, String region, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Duration timeout) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.- Parameters:
modelId
- The model id to use. See theAnthropicChatBedrockApi.AnthropicChatModel
for the supported models.credentialsProvider
- The credentials provider to connect to AWS.region
- The AWS region to use.objectMapper
- The object mapper to use for JSON serialization and deserialization.timeout
- The timeout to use.
-
AnthropicChatBedrockApi
public AnthropicChatBedrockApi(String modelId, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentialsProvider, software.amazon.awssdk.regions.Region region, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Duration timeout) Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.- Parameters:
modelId
- The model id to use. See theAnthropicChatBedrockApi.AnthropicChatModel
for the supported models.credentialsProvider
- The credentials provider to connect to AWS.region
- The AWS region to use.objectMapper
- The object mapper to use for JSON serialization and deserialization.timeout
- The timeout to use.
-
-
Method Details
-
chatCompletion
public AnthropicChatBedrockApi.AnthropicChatResponse chatCompletion(AnthropicChatBedrockApi.AnthropicChatRequest anthropicRequest) Description copied from class:AbstractBedrockApi
Chat completion invocation.- Overrides:
chatCompletion
in classAbstractBedrockApi<AnthropicChatBedrockApi.AnthropicChatRequest,
AnthropicChatBedrockApi.AnthropicChatResponse, AnthropicChatBedrockApi.AnthropicChatResponse> - Parameters:
anthropicRequest
- The chat completion request.- Returns:
- The chat completion response.
-
chatCompletionStream
public reactor.core.publisher.Flux<AnthropicChatBedrockApi.AnthropicChatResponse> chatCompletionStream(AnthropicChatBedrockApi.AnthropicChatRequest anthropicRequest) Description copied from class:AbstractBedrockApi
Chat completion invocation with streaming response.- Overrides:
chatCompletionStream
in classAbstractBedrockApi<AnthropicChatBedrockApi.AnthropicChatRequest,
AnthropicChatBedrockApi.AnthropicChatResponse, AnthropicChatBedrockApi.AnthropicChatResponse> - Parameters:
anthropicRequest
- The chat completion request.- Returns:
- The chat completion response stream.
-