Skip to content

feat(dotAI): Dot AI LangChain4J - Anthropic#36138

Merged
nollymar merged 7 commits into
mainfrom
dot-ai-langchain-anthropic
Jul 3, 2026
Merged

feat(dotAI): Dot AI LangChain4J - Anthropic#36138
nollymar merged 7 commits into
mainfrom
dot-ai-langchain-anthropic

Conversation

@ihoffmann-dot

Copy link
Copy Markdown
Member

Summary

Adds Anthropic as a supported provider, talking directly to the Anthropic Messages
API with an API key — distinct from accessing Claude models through AWS Bedrock,
which requires AWS infrastructure and IAM credentials.

  • Add langchain4j-anthropic dependency (version via langchain4j BOM)
  • Add AnthropicModelProviderStrategy registered in LangChain4jModelFactory.STRATEGIES
  • Chat + streaming chat via AnthropicChatModel / AnthropicStreamingChatModel
  • Embeddings and image throw UnsupportedOperationException (Anthropic has no such APIs)
  • endpoint config field overrides the default base URL (proxies/gateways)
  • Add 8 unit tests in LangChain4jModelFactoryTest

Configuration

{
  "chat": {
    "provider": "anthropic",
    "model": "claude-sonnet-4-6",
    "apiKey": "sk-ant-...",
    "maxTokens": 4096,
    "temperature": 0.7
  }
}

Notes

  • Model IDs use the Anthropic form: claude-sonnet-4-6, claude-opus-4-8, claude-haiku-4-5.
  • maxRetries is not supported by the streaming chat model and is ignored with a warning (same behavior as the OpenAI provider).

Related Issue

This PR fixes #36135
EPIC: dotAI Multi-Provider Support #33970

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @ihoffmann-dot's task in 36s —— View job


I'll analyze this and get back to you.

Comment thread dotCMS/pom.xml
@dotCMS dotCMS deleted a comment from github-actions Bot Jul 1, 2026
@dotCMS dotCMS deleted a comment from github-actions Bot Jul 1, 2026
@dotCMS dotCMS deleted a comment from github-actions Bot Jul 1, 2026
@dotCMS dotCMS deleted a comment from github-actions Bot Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🤖 dotBot Review (Bedrock)

Reviewed 5 file(s); 3 candidate(s) → 3 confirmed, 0 uncertain (unverified, kept for review).

Confirmed findings

  • 🟡 Medium dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/AnthropicModelProviderStrategy.java:55 — Negative timeout value not validated
    The code uses config.timeout() directly in Duration.ofSeconds() without validation. If the configured timeout is negative, this creates a negative duration which may cause unexpected behavior in the Anthropic client. The AIConfig's timeout value (likely from user-provided JSON) isn't validated here, and the client may not handle negative durations properly.
  • 🟡 Medium dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/ProviderConfig.java:58 — Missing configuration parameters in Anthropic Javadoc
    The Javadoc for Anthropic configuration in ProviderConfig.java lists only 'apiKey', 'model', and 'endpoint' as parameters, but the PR's example configuration includes 'maxTokens' and 'temperature'. This creates documentation inconsistency, as users may not realize these optional parameters are available for tuning the Anthropic model.
  • 🟡 Medium dotCMS/src/test/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactoryTest.java:602 — Test does not validate custom endpoint configuration is applied
    The test 'test_buildChatModel_anthropic_customEndpoint_returnsModel' configures a custom endpoint but only asserts the model is non-null. It lacks an assertion to verify the AnthropicChatModel instance actually uses the configured endpoint URL, leaving a gap in test coverage for endpoint overrides.

us.deepseek.r1-v1:0 · Run: #28672626375 · tokens: in: 35391 · out: 9608 · total: 44999 · calls: 14 · est. ~$0.100

@ihoffmann-dot ihoffmann-dot marked this pull request as ready for review July 2, 2026 17:27
@nollymar nollymar enabled auto-merge July 3, 2026 18:21
@nollymar nollymar added this pull request to the merge queue Jul 3, 2026
@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merge Queue Status

This pull request spent 3 minutes 52 seconds in the queue, including 3 minutes 34 seconds running CI.

Waiting for any of
  • check-neutral = Finalize / Final Status
  • check-skipped = Finalize / Final Status
  • check-success = Finalize / Final Status
All conditions

Reason

The merge conditions cannot be satisfied due to failing checks

  • Finalize / Final Status
  • Initialize / Initialize

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@mergify mergify Bot added the queued label Jul 3, 2026
mergify Bot added a commit that referenced this pull request Jul 3, 2026
@mergify mergify Bot added dequeued and removed queued labels Jul 3, 2026
Merged via the queue into main with commit 84c501a Jul 3, 2026
70 checks passed
@nollymar nollymar deleted the dot-ai-langchain-anthropic branch July 3, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code dequeued

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEATURE] dotAI: LangChain4J integration — Phase 2 (Anthropic)

2 participants