Skip to content

Commit 0d2d4b7

Browse files
tzolovmarkpollack
authored andcommitted
Add Bedrock Converse API chat model support
Introduces support for Amazon Bedrock Converse API through a new BedrockProxyChatModel implementation. This enables integration with Bedrock's conversation models with features including: - Support for sync/async chat completions - Stream response handling - Tool/function calling capabilities - System message support - Image input support - Observation and metrics integration - Configurable model parameters and AWS credentials Adds core support classes: - BedrockUsage: Implements Usage interface for token tracking - ConverseApiUtils: Utility class for handling Bedrock API responses including: - Tool use event aggregation and processing - Chat response transformation from stream outputs - Model options conversion - Support for metadata aggregation - URLValidator: Utility for URL validation and normalization with support for: - Basic and strict URL validation - URL normalization - Multimodal input handling - Enhanced FunctionCallingOptionsBuilder with merge capabilities for both ChatOptions and FunctionCallingOptions - Added BEDROCK_CONVERSE to AiProvider enum for metrics tracking - Extended AWS credentials support with session token capability - Added configurable session token property to BedrockAwsConnectionProperties Adds new auto-configuration support: - BedrockConverseProxyChatAutoConfiguration for automatic setup of the Bedrock Converse chat model - BedrockConverseProxyChatProperties for configuration including: - Model selection (defaults to Claude 3 Sonnet) - Timeout settings (defaults to 5 minutes) - Temperature and token control - Top-K and Top-P sampling parameters - Integration with existing BedrockAwsConnectionConfiguration for AWS credentials Updates to testing infrastructure: - Adds comprehensive test suite for Bedrock Converse properties and auto-configuration - Integration tests for chat completion and streaming scenarios - Property validation tests for configuration options - Temporarily disabled other Bedrock tests due to AWS quota limitations - Added ObjectMapper configuration for proper JSON handling Added new spring-ai-bedrock-converse-spring-boot-starter module Updates module configuration in parent POM and BOM to include new bedrock-converse modules and starters. Adds necessary auto-configuration imports for seamless integration with Spring Boot applications. Unrelated changes: - Disabled several Bedrock model tests (Jurassic2, Llama, Titan) due to AWS quota limitations - Disabled PaLM2 tests due to API decommissioning by Google Resolves #809, #802 Add docs and fix configs - Move timeout configuration from chat properties to connection properties - Add comprehensive documentation for Bedrock Converse API usage and configuration - Update tests to reflect configuration changes Co-authored-by: maxjiang153 <[email protected]> Standardize AWS credential handling in integration tests - Improve how we manage AWS credentials across our integration test suite and ensures consistent test configuration. We're replacing individual environment variable checks with @RequiresAwsCredentials annotation and standardizing the use of BedrockTestUtils for context creation in tests We also align all AWS regions to US_EAST_1 for consistency and add missing dependency versioning for Oracle Free. These changes make our AWS tests more easier to maintain. Key changes: - Replace @EnabledIfEnvironmentVariable with @RequiresAwsCredentials - Standardize context creation via BedrockTestUtils - Set AWS region to US_EAST_1 - Add Oracle Free dependency version in pom.xml
1 parent 932fc87 commit 0d2d4b7

File tree

51 files changed

+3854
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3854
-145
lines changed
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.springframework.ai</groupId>
8+
<artifactId>spring-ai</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
<relativePath>../../pom.xml</relativePath>
11+
</parent>
12+
<artifactId>spring-ai-bedrock-converse</artifactId>
13+
<packaging>jar</packaging>
14+
<name>Spring AI Model - Amazon Bedrock Converse API</name>
15+
<description>Amazon Bedrock models support using the Converse API</description>
16+
<url>https://github.com/spring-projects/spring-ai</url>
17+
18+
<scm>
19+
<url>https://github.com/spring-projects/spring-ai</url>
20+
<connection>git://github.com/spring-projects/spring-ai.git</connection>
21+
<developerConnection>[email protected]:spring-projects/spring-ai.git</developerConnection>
22+
</scm>
23+
24+
<properties>
25+
<aws.sdk.version>2.29.3</aws.sdk.version>
26+
</properties>
27+
28+
<dependencies>
29+
30+
<!-- production dependencies -->
31+
<dependency>
32+
<groupId>org.springframework.ai</groupId>
33+
<artifactId>spring-ai-core</artifactId>
34+
<version>${project.parent.version}</version>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.ai</groupId>
39+
<artifactId>spring-ai-retry</artifactId>
40+
<version>${project.parent.version}</version>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>software.amazon.awssdk</groupId>
45+
<artifactId>bedrockruntime</artifactId>
46+
<version>${aws.sdk.version}</version>
47+
<exclusions>
48+
<exclusion>
49+
<groupId>commons-logging</groupId>
50+
<artifactId>commons-logging</artifactId>
51+
</exclusion>
52+
</exclusions>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>software.amazon.awssdk</groupId>
57+
<artifactId>sts</artifactId>
58+
<version>${aws.sdk.version}</version>
59+
</dependency>
60+
61+
<dependency>
62+
<groupId>software.amazon.awssdk</groupId>
63+
<artifactId>netty-nio-client</artifactId>
64+
<version>${aws.sdk.version}</version>
65+
</dependency>
66+
67+
<!-- test dependencies -->
68+
<dependency>
69+
<groupId>org.springframework.ai</groupId>
70+
<artifactId>spring-ai-test</artifactId>
71+
<version>${project.version}</version>
72+
<scope>test</scope>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>io.micrometer</groupId>
77+
<artifactId>micrometer-observation-test</artifactId>
78+
<scope>test</scope>
79+
</dependency>
80+
81+
82+
</dependencies>
83+
84+
</project>

0 commit comments

Comments
 (0)