Skip to content

[TASK] dotAI: LangChain4J - Amazon Bedrock provider #35485

@fmontes

Description

@fmontes

Description

Add AWS Bedrock as a supported provider in the dotAI LangChain4J integration layer. 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.

This builds on the LangChain4J abstraction established in #35183 (Phase 1 — OpenAI).

Implementation outline:

  • Add langchain4j-bedrock dependency
  • Add bedrock case to LangChain4jModelFactory switch
  • Implement buildBedrockChatModel using BedrockRuntimeClient with explicit or IAM role credentials
  • Implement buildBedrockEmbeddingModel with automatic Titan/Cohere dispatch by model ID prefix
  • Add embeddingInputType field to ProviderConfig (Cohere-specific; default: search_document)
  • buildBedrockImageModel throws UnsupportedOperationException (no LangChain4J support)

Acceptance Criteria

  • bedrock is selectable as a provider in providerConfig for chat and embeddings sections
  • When accessKeyId / secretAccessKey are omitted, credentials resolve via DefaultCredentialsProvider (IAM role, environment, ~/.aws/credentials)
  • Embedding dispatch routes cohere.* model IDs to BedrockCohereEmbeddingModel and all others to BedrockTitanEmbeddingModel
  • embeddingInputType is honored for Cohere; silently ignored for Titan
  • Image generation throws UnsupportedOperationException with a clear message
  • Unit tests cover Bedrock chat and embedding builders (Titan + Cohere) in LangChain4jModelFactoryTest

Additional Context

Sample configuration:

{
  "chat": {
    "provider": "bedrock",
    "region": "us-east-1",
    "model": "anthropic.claude-3-5-sonnet-20241022-v2:0",
    "maxTokens": 16384
  },
  "embeddings": {
    "provider": "bedrock",
    "region": "us-east-1",
    "model": "amazon.titan-embed-text-v2:0"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions