feat(dotAI): Dot AI LangChain4J - Amazon Bedrock#35242
feat(dotAI): Dot AI LangChain4J - Amazon Bedrock#35242ihoffmann-dot wants to merge 9 commits intodot-ai-langchain-azure-openaifrom
Conversation
❌ Issue Linking RequiredThis PR could not be linked to an issue. All PRs must be linked to an issue for tracking purposes. How to fix this:Option 1: Add keyword to PR body (Recommended - auto-removes this comment)
Why is this required?Issue linking ensures proper tracking, documentation, and helps maintain project history. It connects your code changes to the problem they solve.--- This comment was automatically generated by the issue linking workflow |
|
Claude finished @ihoffmann-dot's task in 1m 51s —— View job PR Review: feat(dotAI) - Amazon Bedrock
Issues Found1. Silent credential fallback on partial credentials — if (config.accessKeyId() != null && config.secretAccessKey() != null) {
return StaticCredentialsProvider.create(...);
}
return DefaultCredentialsProvider.create(); // ← silent fallbackIf a user sets 2. Blank-string credentials bypass the null check —
3. private static StreamingChatModel buildBedrockStreamingChatModel(final ProviderConfig config) {
return BedrockStreamingChatModel.builder()
.modelId(config.model())
.client(bedrockAsyncClient(config))
.build(); // temperature and maxTokens never applied
}
4. Resource leak: AWS clients are created on every call —
5. Redundant BedrockChatModel.builder()
.modelId(config.model())
.region(Region.of(config.region())) // ← region already set in the client
.client(bedrockClient(config));
6. Dead null-check in if (model != null && model.startsWith("cohere.")) {By the time this line is reached, 7. No test for The test class covers chat, embedding, and image for all three providers, but
|
|
Claude finished @ihoffmann-dot's task in 54s —— View job I'll analyze this and get back to you. |
…a BedrockStreamingChatModel
Summary
Adds AWS Bedrock as a supported provider. Bedrock is a managed platform that
proxies multiple model families (Anthropic, Amazon Titan, Cohere, Meta, etc.)
via a unified Converse API — a single integration covers all of them.
langchain4j-bedrockdependencybedrockcase toLangChain4jModelFactoryswitchbuildBedrockChatModelusingBedrockRuntimeClientwith explicit or IAM role credentialsbuildBedrockEmbeddingModelwith automatic Titan/Cohere dispatch by model ID prefixembeddingInputTypefield toProviderConfig(Cohere-specific; default:search_document)buildBedrockImageModelthrowsUnsupportedOperationException(no LangChain4J support)LangChain4jModelFactoryTestConfiguration
{ "chat": { "provider": "bedrock", "region": "us-east-1", "accessKeyId": "...", "secretAccessKey": "...", "model": "anthropic.claude-3-5-sonnet-20241022-v2:0", "maxTokens": 16384, "temperature": 1.0 }, "embeddings": { "provider": "bedrock", "region": "us-east-1", "accessKeyId": "...", "secretAccessKey": "...", "model": "amazon.titan-embed-text-v2:0" } }Notes
accessKeyId/secretAccessKeyare omitted, credentials resolve viaDefaultCredentialsProvider(IAM role, environment, ~/.aws/credentials).cohere. →BedrockCohereEmbeddingModel; all others →BedrockTitanEmbeddingModel.embeddingInputTypeis Cohere-only. Usesearch_documentwhen indexing content,search_querywhen embedding a search query. Titan silently ignores this field.UnsupportedOperationException.Related Issue
This PR fixes #35183
EPIC: dotAI Multi-Provider Support #33970