Add support of Bedrock API timeout
Configure the amount of time to allow the client to complete the execution of an API call.
This timeout covers the entire client execution except for marshalling. This includes request handler execution,
all HTTP requests including retries, unmarshalling, etc. This value should always be positive, if present.
- Add timeout filed to the AbstractBedrockApi, used to initialize the BedrockRuntimeClient and the
BedrockStreamingRuntimeClient. Update all classes that extend the AbstractBedrockApi.
- Keep the previous constructors for backward compatibility using timeout value of 5 min.
- Add a common AWS connection timeout auto-config property and update the documentation.
Defaults to 5 min.
Additional changes:
- Fix Anthropic 3 straming response - add bedrock metrics field.
- Increate the default timeout to 5 min. Update the docs.
- Increase the ITs.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.anthropic.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -54,6 +55,16 @@ public class AnthropicChatBedrockApi extends
|
||||
super(modelId, region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.
|
||||
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public AnthropicChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
@@ -67,6 +78,20 @@ public class AnthropicChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public AnthropicChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
// https://github.com/build-on-aws/amazon-bedrock-java-examples/blob/main/example_code/bedrock-runtime/src/main/java/aws/community/examples/InvokeBedrockStreamingAsync.java
|
||||
|
||||
// https://docs.anthropic.com/claude/reference/complete_post
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
|
||||
import reactor.core.publisher.Flux;
|
||||
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -58,6 +59,16 @@ public class Anthropic3ChatBedrockApi extends
|
||||
super(modelId, region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the default credentials provider chain, the default object.
|
||||
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Anthropic3ChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
@@ -71,6 +82,20 @@ public class Anthropic3ChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Anthropic3ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
// https://github.com/build-on-aws/amazon-bedrock-java-examples/blob/main/example_code/bedrock-runtime/src/main/java/aws/community/examples/InvokeBedrockStreamingAsync.java
|
||||
|
||||
// https://docs.anthropic.com/claude/reference/complete_post
|
||||
@@ -307,10 +332,12 @@ public class Anthropic3ChatBedrockApi extends
|
||||
* @param usage Metrics about the model invocation.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public record AnthropicChatResponse(@JsonProperty("id") String id, @JsonProperty("model") String model,
|
||||
@JsonProperty("type") String type, @JsonProperty("role") String role,
|
||||
@JsonProperty("content") List<MediaContent> content, @JsonProperty("stop_reason") String stopReason,
|
||||
@JsonProperty("stop_sequence") String stopSequence, @JsonProperty("usage") AnthropicUsage usage) {
|
||||
public record AnthropicChatResponse(// formatter:off
|
||||
@JsonProperty("id") String id, @JsonProperty("model") String model, @JsonProperty("type") String type,
|
||||
@JsonProperty("role") String role, @JsonProperty("content") List<MediaContent> content,
|
||||
@JsonProperty("stop_reason") String stopReason, @JsonProperty("stop_sequence") String stopSequence,
|
||||
@JsonProperty("usage") AnthropicUsage usage,
|
||||
@JsonProperty("amazon-bedrock-invocationMetrics") AmazonBedrockInvocationMetrics amazonBedrockInvocationMetrics) { // formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,10 +353,11 @@ public class Anthropic3ChatBedrockApi extends
|
||||
* @param usage The usage data.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
public record AnthropicChatStreamingResponse(@JsonProperty("type") StreamingType type,
|
||||
@JsonProperty("message") AnthropicChatResponse message, @JsonProperty("index") Integer index,
|
||||
@JsonProperty("content_block") MediaContent contentBlock, @JsonProperty("delta") Delta delta,
|
||||
@JsonProperty("usage") AnthropicUsage usage) {
|
||||
public record AnthropicChatStreamingResponse(// formatter:off
|
||||
@JsonProperty("type") StreamingType type, @JsonProperty("message") AnthropicChatResponse message,
|
||||
@JsonProperty("index") Integer index, @JsonProperty("content_block") MediaContent contentBlock,
|
||||
@JsonProperty("delta") Delta delta, @JsonProperty("usage") AnthropicUsage usage,
|
||||
@JsonProperty("amazon-bedrock-invocationMetrics") AmazonBedrockInvocationMetrics amazonBedrockInvocationMetrics) { // formatter:on
|
||||
|
||||
/**
|
||||
* The streaming type of this message.
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -44,6 +43,9 @@ import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithRespo
|
||||
import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelWithResponseStreamResponseHandler;
|
||||
import software.amazon.awssdk.services.bedrockruntime.model.ResponseStream;
|
||||
|
||||
import org.springframework.ai.model.ModelOptionsUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract class for the Bedrock API. It provides the basic functionality to invoke the chat completion model and
|
||||
* receive the response for streaming and non-streaming requests.
|
||||
@@ -67,7 +69,6 @@ public abstract class AbstractBedrockApi<I, O, SO> {
|
||||
|
||||
private final String modelId;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final AwsCredentialsProvider credentialsProvider;
|
||||
private final String region;
|
||||
private final BedrockRuntimeClient client;
|
||||
private final BedrockRuntimeAsyncClient clientStreaming;
|
||||
@@ -79,10 +80,20 @@ public abstract class AbstractBedrockApi<I, O, SO> {
|
||||
* @param region The AWS region to use.
|
||||
*/
|
||||
public AbstractBedrockApi(String modelId, String region) {
|
||||
this(modelId, ProfileCredentialsProvider.builder().build(), region, new ObjectMapper());
|
||||
this(modelId, ProfileCredentialsProvider.builder().build(), region, ModelOptionsUtils.OBJECT_MAPPER, Duration.ofMinutes(5));
|
||||
}
|
||||
/**
|
||||
* Create a new AbstractBedrockApi instance using default credentials provider and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public AbstractBedrockApi(String modelId, String region, Duration timeout) {
|
||||
this(modelId, ProfileCredentialsProvider.builder().build(), region, ModelOptionsUtils.OBJECT_MAPPER, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Create a new AbstractBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use.
|
||||
@@ -91,21 +102,44 @@ public abstract class AbstractBedrockApi<I, O, SO> {
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
*/
|
||||
public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper) {
|
||||
ObjectMapper objectMapper) {
|
||||
this(modelId, credentialsProvider, region, objectMapper, Duration.ofMinutes(5));
|
||||
}
|
||||
/**
|
||||
* Create a new AbstractBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout Configure the amount of time to allow the client to complete the execution of an API call.
|
||||
* This timeout covers the entire client execution except for marshalling. This includes request handler execution,
|
||||
* all HTTP requests including retries, unmarshalling, etc. This value should always be positive, if present.
|
||||
*/
|
||||
public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
|
||||
Assert.hasText(modelId, "Model id must not be empty");
|
||||
Assert.notNull(credentialsProvider, "Credentials provider must not be null");
|
||||
Assert.hasText(region, "Region must not be empty");
|
||||
Assert.notNull(objectMapper, "Object mapper must not be null");
|
||||
Assert.notNull(timeout, "Timeout must not be null");
|
||||
|
||||
this.modelId = modelId;
|
||||
this.objectMapper = objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
this.credentialsProvider = credentialsProvider;
|
||||
this.objectMapper = objectMapper;
|
||||
this.region = region;
|
||||
|
||||
|
||||
this.client = BedrockRuntimeClient.builder()
|
||||
.region(Region.of(this.region))
|
||||
.credentialsProvider(this.credentialsProvider)
|
||||
.credentialsProvider(credentialsProvider)
|
||||
.overrideConfiguration(c -> c.apiCallTimeout(timeout))
|
||||
.build();
|
||||
|
||||
this.clientStreaming = BedrockRuntimeAsyncClient.builder()
|
||||
.region(Region.of(this.region))
|
||||
.credentialsProvider(this.credentialsProvider)
|
||||
.credentialsProvider(credentialsProvider)
|
||||
.overrideConfiguration(c -> c.apiCallTimeout(timeout))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -113,14 +147,14 @@ public abstract class AbstractBedrockApi<I, O, SO> {
|
||||
* @return The model id.
|
||||
*/
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The AWS region.
|
||||
*/
|
||||
public String getRegion() {
|
||||
return region;
|
||||
return this.region;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// @formatter:off
|
||||
package org.springframework.ai.bedrock.cohere.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -64,6 +65,32 @@ public class CohereChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CohereChatBedrockApi instance using the default credentials provider chain, the default object
|
||||
* mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link CohereChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public CohereChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CohereChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link CohereChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public CohereChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* CohereChatRequest encapsulates the request parameters for the Cohere command model.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// @formatter:off
|
||||
package org.springframework.ai.bedrock.cohere.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -63,6 +64,33 @@ public class CohereEmbeddingBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CohereEmbeddingBedrockApi instance using the default credentials provider chain, the default object
|
||||
* mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link CohereEmbeddingModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public CohereEmbeddingBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CohereEmbeddingBedrockApi instance using the provided credentials provider, region and object
|
||||
* mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link CohereEmbeddingModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public CohereEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cohere Embed model request.
|
||||
*
|
||||
@@ -140,6 +168,7 @@ public class CohereEmbeddingBedrockApi extends
|
||||
@JsonProperty("id") String id,
|
||||
@JsonProperty("embeddings") List<List<Double>> embeddings,
|
||||
@JsonProperty("texts") List<String> texts,
|
||||
@JsonProperty("response_type") String responseType,
|
||||
// For future use: Currently bedrock doesn't return invocationMetrics for the cohere embedding model.
|
||||
@JsonProperty("amazon-bedrock-invocationMetrics") AmazonBedrockInvocationMetrics amazonBedrockInvocationMetrics) {
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// @formatter:off
|
||||
package org.springframework.ai.bedrock.jurassic2.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -64,6 +65,32 @@ public class Ai21Jurassic2ChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Ai21Jurassic2ChatBedrockApi instance using the default credentials provider chain, the default
|
||||
* object mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Ai21Jurassic2ChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Ai21Jurassic2ChatBedrockApi instance.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Ai21Jurassic2ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* AI21 Jurassic2 chat request parameters.
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.springframework.ai.bedrock.api.AbstractBedrockApi;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatRequest;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatResponse;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
* Java client for the Bedrock Llama2 chat model.
|
||||
@@ -61,6 +63,32 @@ public class Llama2ChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Llama2ChatBedrockApi instance using the default credentials provider chain, the default object
|
||||
* mapper, default temperature and topP values.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Llama2ChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Llama2ChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link Llama2ChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public Llama2ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Llama2ChatRequest encapsulates the request parameters for the Meta Llama2 chat model.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.titan.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -43,6 +44,12 @@ import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatRes
|
||||
public class TitanChatBedrockApi extends
|
||||
AbstractBedrockApi<TitanChatRequest, TitanChatResponse, TitanChatResponseChunk> {
|
||||
|
||||
/**
|
||||
* Create a new TitanChatBedrockApi instance using the default credentials provider chain, the default object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link TitanChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
*/
|
||||
public TitanChatBedrockApi(String modelId, String region) {
|
||||
super(modelId, region);
|
||||
}
|
||||
@@ -60,6 +67,31 @@ public class TitanChatBedrockApi extends
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TitanChatBedrockApi instance using the default credentials provider chain, the default object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link TitanChatModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public TitanChatBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TitanChatBedrockApi instance using the provided credentials provider, region and object mapper.
|
||||
*
|
||||
* @param modelId The model id to use. See the {@link TitanChatModel} for the supported models.
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public TitanChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* TitanChatRequest encapsulates the request parameters for the Titan chat model.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.titan.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -44,9 +45,10 @@ public class TitanEmbeddingBedrockApi extends
|
||||
* mapper.
|
||||
* @param modelId The model id to use. See the {@link TitanEmbeddingModel} for the supported models.
|
||||
* @param region The AWS region to use.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public TitanEmbeddingBedrockApi(String modelId, String region) {
|
||||
super(modelId, region);
|
||||
public TitanEmbeddingBedrockApi(String modelId, String region, Duration timeout) {
|
||||
super(modelId, region, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,10 +58,11 @@ public class TitanEmbeddingBedrockApi extends
|
||||
* @param credentialsProvider The credentials provider to connect to AWS.
|
||||
* @param region The AWS region to use.
|
||||
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
|
||||
* @param timeout The timeout to use.
|
||||
*/
|
||||
public TitanEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
|
||||
ObjectMapper objectMapper) {
|
||||
super(modelId, credentialsProvider, region, objectMapper);
|
||||
ObjectMapper objectMapper, Duration timeout) {
|
||||
super(modelId, credentialsProvider, region, objectMapper, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.anthropic;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -204,7 +205,8 @@ class BedrockAnthropicChatClientIT {
|
||||
@Bean
|
||||
public AnthropicChatBedrockApi anthropicApi() {
|
||||
return new AnthropicChatBedrockApi(AnthropicChatBedrockApi.AnthropicChatModel.CLAUDE_V2.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.anthropic;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -32,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BedrockAnthropicCreateRequestTests {
|
||||
|
||||
private AnthropicChatBedrockApi anthropicChatApi = new AnthropicChatBedrockApi(AnthropicChatModel.CLAUDE_V2.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(), Duration.ofMillis(1000L));
|
||||
|
||||
@Test
|
||||
public void createRequestWithChatOptions() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.anthropic.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -43,7 +44,8 @@ public class AnthropicChatBedrockApiIT {
|
||||
private final Logger logger = LoggerFactory.getLogger(AnthropicChatBedrockApiIT.class);
|
||||
|
||||
private AnthropicChatBedrockApi anthropicChatApi = new AnthropicChatBedrockApi(AnthropicChatModel.CLAUDE_V2.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_WEST_2.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
|
||||
@@ -49,6 +49,7 @@ import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsPro
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -223,7 +224,8 @@ class BedrockAnthropic3ChatClientIT {
|
||||
@Bean
|
||||
public Anthropic3ChatBedrockApi anthropicApi() {
|
||||
return new Anthropic3ChatBedrockApi(Anthropic3ChatBedrockApi.AnthropicChatModel.CLAUDE_V3_SONNET.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(5));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.ai.bedrock.anthropic3.api.Anthropic3ChatBedrockApi.An
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -31,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BedrockAnthropic3CreateRequestTests {
|
||||
|
||||
private Anthropic3ChatBedrockApi anthropicChatApi = new Anthropic3ChatBedrockApi(AnthropicChatModel.CLAUDE_V2.id(),
|
||||
Region.EU_CENTRAL_1.id());
|
||||
Region.EU_CENTRAL_1.id(), Duration.ofMillis(1000L));
|
||||
|
||||
@Test
|
||||
public void createRequestWithChatOptions() {
|
||||
|
||||
@@ -31,6 +31,7 @@ import reactor.core.publisher.Flux;
|
||||
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class Anthropic3ChatBedrockApiIT {
|
||||
|
||||
private Anthropic3ChatBedrockApi anthropicChatApi = new Anthropic3ChatBedrockApi(
|
||||
AnthropicChatModel.CLAUDE_INSTANT_V1.id(), EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(), new ObjectMapper());
|
||||
Region.US_EAST_1.id(), new ObjectMapper(), Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
@@ -64,7 +65,8 @@ public class Anthropic3ChatBedrockApiIT {
|
||||
|
||||
AnthropicChatResponse response = anthropicChatApi.chatCompletion(request);
|
||||
|
||||
System.out.println(response.content());
|
||||
logger.info("" + response.content());
|
||||
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.content().get(0).text()).isNotEmpty();
|
||||
assertThat(response.content().get(0).text()).contains("Blackbeard");
|
||||
@@ -103,7 +105,7 @@ public class Anthropic3ChatBedrockApiIT {
|
||||
|
||||
AnthropicChatResponse response = anthropicChatApi.chatCompletion(request);
|
||||
|
||||
System.out.println(response.content());
|
||||
logger.info("" + response.content());
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.content().get(0).text()).isNotEmpty();
|
||||
assertThat(response.content().get(0).text()).contains("Blackbeard");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.cohere;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -200,7 +201,8 @@ class BedrockCohereChatClientIT {
|
||||
@Bean
|
||||
public CohereChatBedrockApi cohereApi() {
|
||||
return new CohereChatBedrockApi(CohereChatModel.COHERE_COMMAND_V14.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.cohere;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -38,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BedrockCohereChatCreateRequestTests {
|
||||
|
||||
private CohereChatBedrockApi chatApi = new CohereChatBedrockApi(CohereChatModel.COHERE_COMMAND_V14.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void createRequestWithChatOptions() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.cohere;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -87,7 +88,8 @@ class BedrockCohereEmbeddingClientIT {
|
||||
@Bean
|
||||
public CohereEmbeddingBedrockApi cohereEmbeddingApi() {
|
||||
return new CohereEmbeddingBedrockApi(CohereEmbeddingModel.COHERE_EMBED_MULTILINGUAL_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.cohere.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -39,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;;
|
||||
public class CohereChatBedrockApiIT {
|
||||
|
||||
private CohereChatBedrockApi cohereChatApi = new CohereChatBedrockApi(CohereChatModel.COHERE_COMMAND_V14.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void requestBuilder() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.cohere.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -38,7 +39,7 @@ public class CohereEmbeddingBedrockApiIT {
|
||||
|
||||
CohereEmbeddingBedrockApi api = new CohereEmbeddingBedrockApi(
|
||||
CohereEmbeddingModel.COHERE_EMBED_MULTILINGUAL_V1.id(), EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(), new ObjectMapper());
|
||||
Region.US_EAST_1.id(), new ObjectMapper(), Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void embedText() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.jurassic2.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -35,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class Ai21Jurassic2ChatBedrockApiIT {
|
||||
|
||||
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2ChatModel.AI21_J2_ULTRA_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.core.io.Resource;
|
||||
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -146,7 +147,8 @@ class BedrockAi21Jurassic2ChatClientIT {
|
||||
public Ai21Jurassic2ChatBedrockApi jurassic2ChatBedrockApi() {
|
||||
return new Ai21Jurassic2ChatBedrockApi(
|
||||
Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel.AI21_J2_MID_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.llama2;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -205,7 +206,8 @@ class BedrockLlama2ChatClientIT {
|
||||
@Bean
|
||||
public Llama2ChatBedrockApi llama2Api() {
|
||||
return new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi;
|
||||
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi.Llama2ChatModel;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -32,7 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BedrockLlama2CreateRequestTests {
|
||||
|
||||
private Llama2ChatBedrockApi api = new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void createRequestWithChatOptions() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.llama2.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -36,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class Llama2ChatBedrockApiIT {
|
||||
|
||||
private Llama2ChatBedrockApi llama2ChatApi = new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void chatCompletion() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.titan;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -206,7 +207,8 @@ class BedrockTitanChatClientIT {
|
||||
@Bean
|
||||
public TitanChatBedrockApi titanApi() {
|
||||
return new TitanChatBedrockApi(TitanChatModel.TITAN_TEXT_EXPRESS_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.titan;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -34,7 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BedrockTitanChatCreateRequestTests {
|
||||
|
||||
private TitanChatBedrockApi api = new TitanChatBedrockApi(TitanChatModel.TITAN_TEXT_EXPRESS_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
|
||||
Duration.ofMinutes(2));
|
||||
|
||||
@Test
|
||||
public void createRequestWithChatOptions() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.ai.bedrock.titan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,7 +70,8 @@ class BedrockTitanEmbeddingClientIT {
|
||||
|
||||
@Bean
|
||||
public TitanEmbeddingBedrockApi titanEmbeddingApi() {
|
||||
return new TitanEmbeddingBedrockApi(TitanEmbeddingModel.TITAN_EMBED_IMAGE_V1.id(), Region.US_EAST_1.id());
|
||||
return new TitanEmbeddingBedrockApi(TitanEmbeddingModel.TITAN_EMBED_IMAGE_V1.id(), Region.US_EAST_1.id(),
|
||||
Duration.ofMinutes(2));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ai.bedrock.titan.api;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -38,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class TitanChatBedrockApiIT {
|
||||
|
||||
TitanChatBedrockApi titanBedrockApi = new TitanChatBedrockApi(TitanChatModel.TITAN_TEXT_EXPRESS_V1.id(),
|
||||
Region.EU_CENTRAL_1.id());
|
||||
Region.EU_CENTRAL_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
TitanChatRequest titanChatRequest = TitanChatRequest.builder("Give me the names of 3 famous pirates?")
|
||||
.withTemperature(0.5f)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.ai.bedrock.titan.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -40,7 +41,7 @@ public class TitanEmbeddingBedrockApiIT {
|
||||
public void embedText() {
|
||||
|
||||
TitanEmbeddingBedrockApi titanEmbedApi = new TitanEmbeddingBedrockApi(
|
||||
TitanEmbeddingModel.TITAN_EMBED_TEXT_V1.id(), Region.US_EAST_1.id());
|
||||
TitanEmbeddingModel.TITAN_EMBED_TEXT_V1.id(), Region.US_EAST_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
TitanEmbeddingRequest request = TitanEmbeddingRequest.builder().withInputText("I like to eat apples.").build();
|
||||
|
||||
@@ -55,7 +56,7 @@ public class TitanEmbeddingBedrockApiIT {
|
||||
public void embedImage() throws IOException {
|
||||
|
||||
TitanEmbeddingBedrockApi titanEmbedApi = new TitanEmbeddingBedrockApi(
|
||||
TitanEmbeddingModel.TITAN_EMBED_IMAGE_V1.id(), Region.US_EAST_1.id());
|
||||
TitanEmbeddingModel.TITAN_EMBED_IMAGE_V1.id(), Region.US_EAST_1.id(), Duration.ofMinutes(2));
|
||||
|
||||
byte[] image = new DefaultResourceLoader().getResource("classpath:/spring_framework.png")
|
||||
.getContentAsByteArray();
|
||||
|
||||
@@ -59,7 +59,7 @@ import org.springframework.util.CollectionUtils;
|
||||
*/
|
||||
public final class ModelOptionsUtils {
|
||||
|
||||
private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
public final static ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
|
||||
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
|
||||
.registerModule(new JavaTimeModule());
|
||||
|
||||
@@ -47,6 +47,8 @@ spring.ai.bedrock.aws.region=us-east-1
|
||||
|
||||
spring.ai.bedrock.aws.access-key=YOUR_ACCESS_KEY
|
||||
spring.ai.bedrock.aws.secret-key=YOUR_SECRET_KEY
|
||||
|
||||
spring.ai.bedrock.aws.timeout=10m
|
||||
----
|
||||
|
||||
The `region` property is compulsory.
|
||||
@@ -74,7 +76,8 @@ Here are the supported `<model>` and `<chat|embedding>` combinations:
|
||||
| llama2 | Yes | Yes | No
|
||||
| jurassic2 | Yes | No | No
|
||||
| cohere | Yes | Yes | Yes
|
||||
| anthropic | Yes | Yes | No
|
||||
| anthropic 2 | Yes | Yes | No
|
||||
| anthropic 3 | Yes | Yes | No
|
||||
| jurassic2 (WIP) | Yes | No | No
|
||||
| titan | Yes | Yes | Yes (however, no batch support)
|
||||
|====
|
||||
@@ -85,13 +88,11 @@ Next, you can use the `spring.ai.bedrock.<model>.<chat|embedding>.*` properties
|
||||
|
||||
For more information, refer to the documentation below for each supported model.
|
||||
|
||||
* xref:api/chat/bedrock/bedrock-anthropic.adoc[Spring AI Bedrock Anthropic Chat]: `spring.ai.bedrock.anthropic.chat.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-anthropic.adoc[Spring AI Bedrock Anthropic 2 Chat]: `spring.ai.bedrock.anthropic.chat.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-anthropic3.adoc[Spring AI Bedrock Anthropic 3 Chat]: `spring.ai.bedrock.anthropic.chat.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-llama2.adoc[Spring AI Bedrock Llama2 Chat]: `spring.ai.bedrock.llama2.chat.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-cohere.adoc[Spring AI Bedrock Cohere Chat]: `spring.ai.bedrock.cohere.chat.enabled=true`
|
||||
* xref:api/embeddings/bedrock-cohere-embedding.adoc[Spring AI Bedrock Cohere Embeddings]: `spring.ai.bedrock.cohere.embedding.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-titan.adoc[Spring AI Bedrock Titan Chat]: `spring.ai.bedrock.titan.chat.enabled=true`
|
||||
* xref:api/embeddings/bedrock-titan-embedding.adoc[Spring AI Bedrock Titan Embeddings]: `spring.ai.bedrock.titan.embedding.enabled=true`
|
||||
* xref:api/chat/bedrock/bedrock-jurassic2.adoc[Spring AI Bedrock Ai21 Jurassic2 Chat]: `spring.ai.bedrock.jurassic2.chat.enabled=true`
|
||||
|
||||
|
||||
// * xref:api/chat/bedrock/bedrock-jurassic2-chat.adoc[(WIP)Spring AI Bedrock Jurassic Chat]: `spring.ai.bedrock.jurassic2.chat.enabled=true`
|
||||
|
||||
@@ -68,7 +68,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -126,6 +127,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -197,7 +199,8 @@ AnthropicChatBedrockApi anthropicApi = new AnthropicChatBedrockApi(
|
||||
AnthropicChatBedrockApi.AnthropicModel.CLAUDE_V2.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.EU_CENTRAL_1.id(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockAnthropicChatClient chatClient = new BedrockAnthropicChatClient(anthropicApi,
|
||||
AnthropicChatOptions.builder()
|
||||
@@ -231,7 +234,7 @@ Here is a simple snippet how to use the api programmatically:
|
||||
[source,java]
|
||||
----
|
||||
AnthropicChatBedrockApi anthropicChatApi = new AnthropicChatBedrockApi(
|
||||
AnthropicModel.CLAUDE_V2.id(), Region.EU_CENTRAL_1.id());
|
||||
AnthropicModel.CLAUDE_V2.id(), Region.EU_CENTRAL_1.id(), Duration.ofMillis(1000L));
|
||||
|
||||
AnthropicChatRequest request = AnthropicChatRequest
|
||||
.builder(String.format(AnthropicChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates"))
|
||||
|
||||
@@ -65,7 +65,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -167,6 +168,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -238,7 +240,8 @@ Anthropic3ChatBedrockApi anthropicApi = new Anthropic3ChatBedrockApi(
|
||||
AnthropicChatBedrockApi.AnthropicModel.CLAUDE_V3_SONNET.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockAnthropic3ChatClient chatClient = new BedrockAnthropic3ChatClient(anthropicApi,
|
||||
AnthropicChatOptions.builder()
|
||||
@@ -268,7 +271,7 @@ Here is a simple snippet how to use the api programmatically:
|
||||
[source,java]
|
||||
----
|
||||
Anthropic3ChatBedrockApi anthropicChatApi = new Anthropic3ChatBedrockApi(
|
||||
AnthropicModel.CLAUDE_V2.id(), Region.EU_CENTRAL_1.id());
|
||||
AnthropicModel.CLAUDE_V2.id(), Region.EU_CENTRAL_1.id(), Duration.ofMillis(1000L));
|
||||
|
||||
AnthropicChatRequest request = AnthropicChatRequest
|
||||
.builder(String.format(Anthropic3ChatBedrockApi.PROMPT_TEMPLATE, "Name 3 famous pirates"))
|
||||
|
||||
@@ -58,7 +58,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -119,6 +120,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -186,7 +188,10 @@ Next, create an https://github.com/spring-projects/spring-ai/blob/main/models/sp
|
||||
[source,java]
|
||||
----
|
||||
CohereChatBedrockApi api = new CohereChatBedrockApi(CohereChatModel.COHERE_COMMAND_V14.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockCohereChatClient chatClient = new BedrockCohereChatClient(api,
|
||||
BedrockCohereChatOptions.builder()
|
||||
@@ -220,7 +225,8 @@ Here is a simple snippet how to use the api programmatically:
|
||||
----
|
||||
CohereChatBedrockApi cohereChatApi = new CohereChatBedrockApi(
|
||||
CohereChatModel.COHERE_COMMAND_V14.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
var request = CohereChatRequest
|
||||
.builder("What is the capital of Bulgaria and what is the size? What it the national anthem?")
|
||||
|
||||
@@ -57,7 +57,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -112,6 +113,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -174,7 +176,10 @@ Next, create an https://github.com/spring-projects/spring-ai/blob/main/models/sp
|
||||
[source,java]
|
||||
----
|
||||
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2ChatModel.AI21_J2_MID_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockAi21Jurassic2ChatClient chatClient = new BedrockAi21Jurassic2ChatClient(api,
|
||||
BedrockAi21Jurassic2ChatOptions.builder()
|
||||
@@ -200,7 +205,8 @@ Here is a simple snippet on how to use the API programmatically:
|
||||
----
|
||||
Ai21Jurassic2ChatBedrockApi jurassic2ChatApi = new Ai21Jurassic2ChatBedrockApi(
|
||||
Ai21Jurassic2ChatModel.AI21_J2_MID_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
Ai21Jurassic2ChatRequest request = Ai21Jurassic2ChatRequest.builder("Hello, my name is")
|
||||
.withTemperature(0.9f)
|
||||
|
||||
@@ -62,7 +62,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -117,6 +118,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -184,7 +186,10 @@ Next, create an https://github.com/spring-projects/spring-ai/blob/main/models/sp
|
||||
[source,java]
|
||||
----
|
||||
Llama2ChatBedrockApi api = new Llama2ChatBedrockApi(Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper());
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockLlama2ChatClient chatClient = new BedrockLlama2ChatClient(api,
|
||||
BedrockLlama2ChatOptions.builder()
|
||||
@@ -216,7 +221,8 @@ Here is a simple snippet how to use the api programmatically:
|
||||
----
|
||||
Llama2ChatBedrockApi llama2ChatApi = new Llama2ChatBedrockApi(
|
||||
Llama2ChatModel.LLAMA2_70B_CHAT_V1.id(),
|
||||
Region.US_EAST_1.id());
|
||||
Region.US_EAST_1.id(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
Llama2ChatRequest request = Llama2ChatRequest.builder("Hello, my name is")
|
||||
.withTemperature(0.9f)
|
||||
|
||||
@@ -59,7 +59,8 @@ The prefix `spring.ai.bedrock.aws` is the property prefix to configure the conne
|
||||
|====
|
||||
| Property | Description | Default
|
||||
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.region | AWS region to use. | us-east-1
|
||||
| spring.ai.bedrock.aws.timeout | AWS timeout to use. | 5m
|
||||
| spring.ai.bedrock.aws.access-key | AWS access key. | -
|
||||
| spring.ai.bedrock.aws.secret-key | AWS secret key. | -
|
||||
|====
|
||||
@@ -115,6 +116,7 @@ Add a `application.properties` file, under the `src/main/resources` directory, t
|
||||
[source]
|
||||
----
|
||||
spring.ai.bedrock.aws.region=eu-central-1
|
||||
spring.ai.bedrock.aws.timeout=1000ms
|
||||
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
|
||||
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
|
||||
|
||||
@@ -184,7 +186,9 @@ Next, create an https://github.com/spring-projects/spring-ai/blob/main/models/sp
|
||||
TitanChatBedrockApi titanApi = new TitanChatBedrockApi(
|
||||
TitanChatModel.TITAN_TEXT_EXPRESS_V1.id(),
|
||||
EnvironmentVariableCredentialsProvider.create(),
|
||||
Region.US_EAST_1.id(), new ObjectMapper());
|
||||
Region.US_EAST_1.id(),
|
||||
new ObjectMapper(),
|
||||
Duration.ofMillis(1000L));
|
||||
|
||||
BedrockTitanChatClient chatClient = new BedrockTitanChatClient(titanApi,
|
||||
BedrockTitanChatOptions.builder()
|
||||
@@ -216,7 +220,7 @@ Here is a simple snippet how to use the api programmatically:
|
||||
[source,java]
|
||||
----
|
||||
TitanChatBedrockApi titanBedrockApi = new TitanChatBedrockApi(TitanChatCompletionModel.TITAN_TEXT_EXPRESS_V1.id(),
|
||||
Region.EU_CENTRAL_1.id());
|
||||
Region.EU_CENTRAL_1.id(), Duration.ofMillis(1000L));
|
||||
|
||||
TitanChatRequest titanChatRequest = TitanChatRequest.builder("Give me the names of 3 famous pirates?")
|
||||
.withTemperature(0.5f)
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.ai.autoconfigure.bedrock;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Configuration properties for Bedrock AWS connection.
|
||||
*
|
||||
@@ -43,6 +45,11 @@ public class BedrockAwsConnectionProperties {
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* Set model timeout, Defaults 5 min.
|
||||
*/
|
||||
private Duration timeout = Duration.ofMinutes(5L);
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
@@ -67,4 +74,12 @@ public class BedrockAwsConnectionProperties {
|
||||
this.secretKey = secretKey;
|
||||
}
|
||||
|
||||
public Duration getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Duration timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BedrockAnthropicChatAutoConfiguration {
|
||||
public AnthropicChatBedrockApi anthropicApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockAnthropicChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new AnthropicChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BedrockAnthropic3ChatAutoConfiguration {
|
||||
public Anthropic3ChatBedrockApi anthropicApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockAnthropic3ChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new Anthropic3ChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -47,7 +47,7 @@ public class BedrockCohereChatAutoConfiguration {
|
||||
public CohereChatBedrockApi cohereChatApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockCohereChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new CohereChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BedrockCohereEmbeddingAutoConfiguration {
|
||||
public CohereEmbeddingBedrockApi cohereEmbeddingApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockCohereEmbeddingProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new CohereEmbeddingBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -49,7 +49,7 @@ public class BedrockAi21Jurassic2ChatAutoConfiguration {
|
||||
public Ai21Jurassic2ChatBedrockApi ai21Jurassic2ChatBedrockApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockAi21Jurassic2ChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new Ai21Jurassic2ChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -50,7 +50,7 @@ public class BedrockLlama2ChatAutoConfiguration {
|
||||
public Llama2ChatBedrockApi llama2Api(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockLlama2ChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new Llama2ChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BedrockTitanChatAutoConfiguration {
|
||||
BedrockTitanChatProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
|
||||
return new TitanChatBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BedrockTitanEmbeddingAutoConfiguration {
|
||||
public TitanEmbeddingBedrockApi titanEmbeddingBedrockApi(AwsCredentialsProvider credentialsProvider,
|
||||
BedrockTitanEmbeddingProperties properties, BedrockAwsConnectionProperties awsProperties) {
|
||||
return new TitanEmbeddingBedrockApi(properties.getModel(), credentialsProvider, awsProperties.getRegion(),
|
||||
new ObjectMapper());
|
||||
new ObjectMapper(), awsProperties.getTimeout());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user