-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ai/bedrock): add Amazon Bedrock provider support #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- Added `aws-config` and `aws-sdk-bedrockruntime` dependencies to enable Amazon Bedrock integration. - Implemented `AmazonBedrockProvider` with support for object generation via the Bedrock Converse API. - Updated `AIProvider` to route object generation requests to Bedrock when selected. - Introduced error handling for Bedrock-specific and deserialization errors. - Refactored provider builder for Bedrock, including region, credentials, and header management. - Added test scaffolding for Bedrock provider. - Updated error types and retry logic to handle new Bedrock error cases.
Implement the `generate_text` method for the `AmazonBedrockProvider`, enabling text generation via Amazon Bedrock. Add request normalization logic and integrate with the provider selection in `AIProvider`. Include unit tests for `generate_text` to verify functionality.
Contributor
Greptile SummaryThis PR adds Amazon Bedrock provider support to the AI module, implementing text and object generation via the Bedrock Converse API. Key Changes:
Critical Issues:
Minor Issues:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant AIProvider
participant AmazonBedrockProvider
participant AWSBedrockClient
participant BedrockAPI
Client->>AIProvider: generate_object(request)
AIProvider->>AIProvider: match provider type
AIProvider->>AmazonBedrockProvider: generate_object(request)
AmazonBedrockProvider->>AmazonBedrockProvider: normalize_generate_object_request()
Note over AmazonBedrockProvider: Extract system message from OpenAIProvider<br/>Build user messages with schema
AmazonBedrockProvider->>AWSBedrockClient: converse().send()
AWSBedrockClient->>BedrockAPI: HTTP Request (Converse API)
alt Success
BedrockAPI-->>AWSBedrockClient: Converse Response
AWSBedrockClient-->>AmazonBedrockProvider: ConverseOutput
AmazonBedrockProvider->>AmazonBedrockProvider: Extract text from output message
AmazonBedrockProvider->>AmazonBedrockProvider: Deserialize JSON to type T
AmazonBedrockProvider-->>AIProvider: GenerateObjectResponse<T>
AIProvider-->>Client: Result<GenerateObjectResponse<T>>
else Error
BedrockAPI-->>AWSBedrockClient: SDK Error
AWSBedrockClient-->>AmazonBedrockProvider: Error
AmazonBedrockProvider-->>AIProvider: ResponseGeneratorError::BedrockConverseError
AIProvider-->>Client: Err(ResponseGeneratorError)
end
|
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 files reviewed, 9 comments
Implement the `generate_text` method for the `AmazonBedrockProvider`, enabling text generation via Amazon Bedrock. Add request normalization logic and integrate with the provider selection in `AIProvider`. Include unit tests for `generate_text` to verify functionality.
Implement the `generate_text` method for the `AmazonBedrockProvider`, enabling text generation via Amazon Bedrock. Add request normalization logic and integrate with the provider selection in `AIProvider`. Include unit tests for `generate_text` to verify functionality.
…vider - Add `aws-smithy-types` dependency to support structured model request fields. - Update `AmazonBedrockProvider` to set `InferenceConfiguration` (temperature, top_p, max_tokens) on Bedrock requests. - Pass custom headers as additional model request fields using `aws_smithy_types::Document`. - Refactor provider builder to use explicit credentials and provider name, removing reliance on environment variables and default headers. - Use `Arc` for Bedrock client to support potential sharing.
… to Bedrock Previously, base64-encoded image data was passed as raw bytes, which could result in invalid images being sent to AWS Bedrock. This change decodes the base64 string before constructing the ImageBlock, ensuring valid image data is used. Also improves error handling and clarifies unimplemented file handling.
…ponse context - Update `ResponseGeneratorError::Deserialization` to include both the serde_json error and the original response string. - Enhance error messages and tracing logs to display both the error and the problematic response, aiding debugging. - Change Amazon Bedrock and OpenAI providers to pass the response text into deserialization errors. - Update error handling in utils to log both error and response content for deserialization failures.
…ement - Enhance AmazonBedrockProvider to use Bedrock's tool use API for structured JSON output. - Add conversion utilities between serde_json::Value and aws_smithy_types::Document. - Update error handling and deserialization logic to support tool use responses. - Configure tool specification and input schema for JSON output in Bedrock requests. - Bump aws-smithy-types dependency to enable required features.
- Introduce `rerank` and `structured_rerank` modules to support ranking and structured ranking of documents. - Add `RerankRequest`, `RerankResponse`, and builder with validation for reranking text documents. - Add `StructuredRerankRequest`, `StructuredRerankResponse`, and builder for reranking structured data with generic support. - Expose new modules in `response_generators::mod.rs`. - Make `generate_text` and `generate_object` requests constructible via builder methods. - Add `serde-saphyr` dependency for structured serialization. - Update `Cargo.lock` with new dependencies and versions.
…nk API to use top_k - Derive Debug for AIProvider, RerankingModel, and provider structs (AmazonBedrockProvider, AzureOpenAIProvider, GoogleVertexAIProvider, GoogleCredentials, XAIProvider, StructuredRerankRequest, StructuredRerankResponse, StructuredRanking, RerankResponse, Ranking) - Refactor rerank API to use `top_k` instead of `top_n` across request structs, builders, and provider implementations - Update Amazon Bedrock provider to require region, fix model ARN construction, and add new rerank/structured_rerank tests - Update Cohere provider to use `top_k` for rerank requests
Sang-it
approved these changes
Jan 20, 2026
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.
aws-configandaws-sdk-bedrockruntimedependencies to enable Amazon Bedrock integration.AmazonBedrockProviderwith support for object generation via the Bedrock Converse API.AIProviderto route object generation requests to Bedrock when selected.