Skip to content

Commit f9f6247

Browse files
committed
AWS/Bedrock housekeeping updates
- upadate bedrockruntime version to 2.26.7 and align it with aws sdk dependecy. - minor ITs configuration, consistency and statbility fixes Use the EnvironmentVariableCredentialsProvider instead of the Profile credential provider. - update the Bedrock getting started documentation. - update the Genemi Prerequisites docs.
1 parent d276d17 commit f9f6247

File tree

8 files changed

+35
-15
lines changed

8 files changed

+35
-15
lines changed

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/anthropic/BedrockAnthropicChatModelIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.stream.Collectors;
2323

2424
import com.fasterxml.jackson.databind.ObjectMapper;
25+
26+
import org.junit.jupiter.api.Disabled;
2527
import org.junit.jupiter.api.Test;
2628
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2729
import org.slf4j.Logger;
@@ -125,6 +127,7 @@ void listOutputConverter() {
125127
assertThat(list).hasSize(5);
126128
}
127129

130+
@Disabled
128131
@Test
129132
void mapOutputConvert() {
130133
MapOutputConverter outputConverter = new MapOutputConverter();
@@ -147,6 +150,7 @@ void mapOutputConvert() {
147150
record ActorsFilmsRecord(String actor, List<String> movies) {
148151
}
149152

153+
@Disabled
150154
@Test
151155
void beanOutputConverterRecords() {
152156

@@ -203,7 +207,7 @@ public static class TestConfiguration {
203207

204208
@Bean
205209
public AnthropicChatBedrockApi anthropicApi() {
206-
return new AnthropicChatBedrockApi(AnthropicChatBedrockApi.AnthropicChatModel.CLAUDE_V2.id(),
210+
return new AnthropicChatBedrockApi(AnthropicChatBedrockApi.AnthropicChatModel.CLAUDE_V21.id(),
207211
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
208212
Duration.ofMinutes(2));
209213
}

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/cohere/api/CohereChatBedrockApiIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import org.junit.jupiter.api.Test;
2222
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2323
import reactor.core.publisher.Flux;
24+
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
2425
import software.amazon.awssdk.regions.Region;
2526

2627
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatModel;
2728
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatRequest;
2829
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatRequest.Truncate;
2930
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatResponse;
3031
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatResponse.Generation.FinishReason;
32+
import org.springframework.ai.model.ModelOptionsUtils;
3133

3234
import static org.assertj.core.api.Assertions.assertThat;
3335
import static org.assertj.core.api.Assertions.assertThatThrownBy;;
@@ -40,7 +42,8 @@
4042
public class CohereChatBedrockApiIT {
4143

4244
private CohereChatBedrockApi cohereChatApi = new CohereChatBedrockApi(CohereChatModel.COHERE_COMMAND_V14.id(),
43-
Region.US_EAST_1.id(), Duration.ofMinutes(2));
45+
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), ModelOptionsUtils.OBJECT_MAPPER,
46+
Duration.ofMinutes(2));
4447

4548
@Test
4649
public void requestBuilder() {

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/BedrockAi21Jurassic2ChatModelIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void mapOutputConverter() {
127127

128128
}
129129

130+
@Disabled("Jurrasic2 is very unstable")
130131
@Test
131132
void simpleChatResponse() {
132133
UserMessage userMessage = new UserMessage("Tell me a joke about AI.");
@@ -146,7 +147,7 @@ public static class TestConfiguration {
146147
@Bean
147148
public Ai21Jurassic2ChatBedrockApi jurassic2ChatBedrockApi() {
148149
return new Ai21Jurassic2ChatBedrockApi(
149-
Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel.AI21_J2_MID_V1.id(),
150+
Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel.AI21_J2_ULTRA_V1.id(),
150151
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), new ObjectMapper(),
151152
Duration.ofMinutes(2));
152153
}

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/jurassic2/api/Ai21Jurassic2ChatBedrockApiIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
import org.junit.jupiter.api.Test;
2222
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
23+
24+
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
2325
import software.amazon.awssdk.regions.Region;
2426

2527
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel;
2628
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatRequest;
2729
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatResponse;
30+
import org.springframework.ai.model.ModelOptionsUtils;
2831

2932
import static org.assertj.core.api.Assertions.assertThat;
3033

@@ -35,8 +38,9 @@
3538
@EnabledIfEnvironmentVariable(named = "AWS_SECRET_ACCESS_KEY", matches = ".*")
3639
public class Ai21Jurassic2ChatBedrockApiIT {
3740

38-
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2ChatModel.AI21_J2_ULTRA_V1.id(),
39-
Region.US_EAST_1.id(), Duration.ofMinutes(2));
41+
Ai21Jurassic2ChatBedrockApi api = new Ai21Jurassic2ChatBedrockApi(Ai21Jurassic2ChatModel.AI21_J2_MID_V1.id(),
42+
EnvironmentVariableCredentialsProvider.create(), Region.US_EAST_1.id(), ModelOptionsUtils.OBJECT_MAPPER,
43+
Duration.ofMinutes(2));
4044

4145
@Test
4246
public void chatCompletion() {

models/spring-ai-bedrock/src/test/java/org/springframework/ai/bedrock/titan/api/TitanChatBedrockApiIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
import org.junit.jupiter.api.Test;
2323
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2424
import reactor.core.publisher.Flux;
25+
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
2526
import software.amazon.awssdk.regions.Region;
2627

2728
import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatModel;
2829
import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatRequest;
2930
import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatResponse;
3031
import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi.TitanChatResponseChunk;
32+
import org.springframework.ai.model.ModelOptionsUtils;
3133

3234
import static org.assertj.core.api.Assertions.assertThat;
3335

@@ -39,7 +41,8 @@
3941
public class TitanChatBedrockApiIT {
4042

4143
TitanChatBedrockApi titanBedrockApi = new TitanChatBedrockApi(TitanChatModel.TITAN_TEXT_EXPRESS_V1.id(),
42-
Region.EU_CENTRAL_1.id(), Duration.ofMinutes(2));
44+
EnvironmentVariableCredentialsProvider.create(), Region.EU_CENTRAL_1.id(), ModelOptionsUtils.OBJECT_MAPPER,
45+
Duration.ofMinutes(2));
4346

4447
TitanChatRequest titanChatRequest = TitanChatRequest.builder("Give me the names of 3 famous pirates?")
4548
.withTemperature(0.5f)

pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@
146146
<azure-open-ai-client.version>1.0.0-beta.8</azure-open-ai-client.version>
147147
<jtokkit.version>1.0.0</jtokkit.version>
148148
<victools.version>4.31.1</victools.version>
149-
<bedrockruntime.version>2.25.3</bedrockruntime.version>
149+
150+
<!-- NOTE: keep them align -->
151+
<bedrockruntime.version>2.26.7</bedrockruntime.version>
152+
<awssdk.version>2.26.7</awssdk.version>
153+
150154
<jackson.version>2.16.1</jackson.version>
151155
<djl.version>0.28.0</djl.version>
152156
<onnxruntime.version>1.17.0</onnxruntime.version>
@@ -178,7 +182,7 @@
178182
<qdrant.version>1.9.1</qdrant.version>
179183
<typesense.version>0.5.0</typesense.version>
180184
<opensearch-client.version>2.10.1</opensearch-client.version>
181-
<awssdk.version>2.20.161</awssdk.version>
185+
182186

183187
<!-- testing dependencies -->
184188
<httpclient5.version>5.3.1</httpclient5.version>

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/bedrock.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Additionally, Spring AI provides Spring Auto-Configurations and Boot Starters fo
1010

1111
There are a few steps to get started
1212

13-
* *Add Boot Starter*: Add the Spring Boot starter for Bedrock to your project.
14-
* *Obtain AWS credentials*: If you don't have an AWS account and AWS CLI configured yet, this video guide can help you configure it: link:https://youtu.be/gswVHTrRX8I?si=buaY7aeI0l3-bBVb[AWS CLI & SDK Setup in Less Than 4 Minutes!]. You should be able to obtain your access and security keys.
15-
* *Enable Bedrock models to use*: Go to link:https://us-east-1.console.aws.amazon.com/bedrock/home[Amazon Bedrock] and from the link:https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess[Model Access] menu on the left, configure access to the models you are going to use.
13+
* Add the Spring Boot starter for Bedrock to your project.
14+
* Obtain AWS credentials: If you don't have an AWS account and AWS CLI configured yet, this video guide can help you configure it: link:https://youtu.be/gswVHTrRX8I?si=buaY7aeI0l3-bBVb[AWS CLI & SDK Setup in Less Than 4 Minutes!]. You should be able to obtain your access and security keys.
15+
* Enable the Models to use: Go to link:https://us-east-1.console.aws.amazon.com/bedrock/home[Amazon Bedrock] and from the link:https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess[Model Access] menu on the left, configure access to the models you are going to use.
1616

1717
=== Project Dependencies
1818

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/vertexai-gemini-chat.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ link:https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemin
1010

1111
== Prerequisites
1212

13-
Set up your Java Development Environment.
14-
Authenticate by running the following command. Replace `PROJECT_ID` with your Google Cloud project ID and `ACCOUNT` with your Google Cloud username.
13+
- Install the link:https://cloud.google.com/sdk/docs/install[gcloud] CLI, apropriate for you OS.
14+
- Authenticate by running the following command.
15+
Replace `PROJECT_ID` with your Google Cloud project ID and `ACCOUNT` with your Google Cloud username.
1516

1617
[source]
1718
----
18-
gcloud config set project PROJECT_ID &&
19-
gcloud auth application-default login ACCOUNT
19+
gcloud config set project <PROJECT_ID> &&
20+
gcloud auth application-default login <ACCOUNT>
2021
----
2122

2223
== Auto-configuration

0 commit comments

Comments
 (0)