Repository navigation
Replies: 2 comments
|
This would be incredibly useful to us! Perhaps it could be backported to 1.1.5? |
|
Thanks for linking the exact commit and mentioning the Boot 3.5 constraint, that made it quick to check every 1.1.x tag against it. It was not backported: 1.1.4 through 1.1.8 all shipped without it, and the spring.io support table lists OSS support for 1.1.x as ended on 2026-06-30 with 1.1.8 as the latest OSS patch, so native
Spring AI 1.1.8 with pom and interceptor used<!-- in dependencyManagement: spring-ai-bedrock-converse 1.1.8 brings bedrockruntime 2.36.3 -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.51.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>record ActorsFilms(String actor, List<String> movies) {}
String schema = new BeanOutputConverter<>(ActorsFilms.class).getJsonSchema();
ExecutionInterceptor jsonSchema = new ExecutionInterceptor() {
@Override
public SdkRequest modifyRequest(Context.ModifyRequest context, ExecutionAttributes attributes) {
if (!(context.request() instanceof ConverseRequest request)) {
return context.request();
}
return request.toBuilder()
.outputConfig(o -> o.textFormat(f -> f.type(OutputFormatType.JSON_SCHEMA)
.structure(s -> s.jsonSchema(j -> j.name("response_schema").schema(schema)))))
.build();
}
};
BedrockProxyChatModel model = BedrockProxyChatModel.builder()
.bedrockRuntimeClient(BedrockRuntimeClient.builder()
.region(Region.US_EAST_1)
.overrideConfiguration(c -> c.addExecutionInterceptor(jsonSchema))
.build())
.defaultOptions(BedrockChatOptions.builder()
.model("us.anthropic.claude-haiku-4-5-20251001-v1:0")
.maxTokens(300)
.build())
.build();
ActorsFilms af = ChatClient.create(model).prompt()
.user("Give me a real actor and three of their movies.")
.call()
.entity(ActorsFilms.class);The Two limits: the interceptor adds that one schema to every Converse call made through the client, so build the client and model only for that output type. And structured output is only available on some Bedrock models (the Bedrock Converse page in the Spring AI docs links AWS's list); Haiku 4.5 is the only one I ran. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I saw that this commit 3003316 was included only in 2.0.0-M3 release. is it possible to be released to in 1.1.4?
For background I still use 3.5 spring boot version and when trying to use 2.0.0-M3 the service brokes
All reactions