Add StructuredOutputChatOptions support to BedrockChatOptions#5501
Closed
chanani wants to merge 3 commits intospring-projects:mainfrom
Closed
Add StructuredOutputChatOptions support to BedrockChatOptions#5501chanani wants to merge 3 commits intospring-projects:mainfrom
chanani wants to merge 3 commits intospring-projects:mainfrom
Conversation
Implemented StructuredOutputChatOptions interface in BedrockChatOptions to provide the foundation for native structured output support on Amazon Bedrock. - Implement StructuredOutputChatOptions interface - Add outputSchema field with getter/setter - Add outputSchema() method to Builder - Add outputSchema copy logic to fromOptions() Closes spring-projectsgh-5445 Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Added unit tests to verify outputSchema functionality in BedrockChatOptions. - Add outputSchema assertions to existing tests (builder, copy, setter, defaultValues) - Add test for StructuredOutputChatOptions interface implementation - Add tests for outputSchema set/get and overwrite Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
- Add buildOutputConfig() to convert outputSchema into AWS OutputConfig - Add outputConfig to ConverseRequest in createRequest() - Add outputConfig to ConverseStreamRequest in internalStream() - Add outputSchema merge logic between runtime/default options in buildRequestPrompt() - Upgrade AWS bedrockruntime SDK from 2.36.3 to 2.41.22 Signed-off-by: CHANHAN <130114269+chanani@users.noreply.github.com>
Contributor
|
@chanani, thank you for your contribution. |
Contributor
|
It looks ok. I will do the rebasing before the merge. |
tzolov
reviewed
Mar 12, 2026
...-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockChatOptionsTests.java
Show resolved
Hide resolved
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add StructuredOutputChatOptions support to BedrockChatOptions
Summary
This PR implements the
StructuredOutputChatOptionsinterface inBedrockChatOptionsto provide the foundation for native structured output support on Amazon Bedrock.Resolves gh-5445
Motivation
Amazon Bedrock now supports native structured output via the
outputConfig.textFormatfield in the Converse API. To enableAdvisorParams.ENABLE_NATIVE_STRUCTURED_OUTPUTfor Bedrock,BedrockChatOptionsneeds to implementStructuredOutputChatOptions, which is the unified abstraction layer used across all providers (Anthropic, Google GenAI, Mistral, OpenAI, etc.).Changes
BedrockChatOptions.java
StructuredOutputChatOptionsinterfaceoutputSchemafield with@JsonIgnoreannotationgetOutputSchema()/setOutputSchema()methodsoutputSchema()method to BuilderoutputSchemacopy logic tofromOptions()BedrockChatOptionsTests.java
outputSchemaassertions to existing tests (builder, copy, setter, defaultValues)StructuredOutputChatOptionsinterface implementationoutputSchemaset/get and overwriteNote
The current AWS SDK version (2.36.3) used by Spring AI does not yet include the
OutputConfigclass for the Converse API. Therefore, this PR stores the output schema as a plainStringfield, consistent with the approach used by other providers like Google GenAI. Once the AWS SDK is upgraded to a version that includesOutputConfig, theBedrockProxyChatModelcan read this field and pass it to the Converse API request.