Skip to content

feat(dotAI): Dot AI LangChain4J - Google AI Gemini#36137

Open
ihoffmann-dot wants to merge 5 commits into
mainfrom
dot-ai-langchain-google-gemini
Open

feat(dotAI): Dot AI LangChain4J - Google AI Gemini#36137
ihoffmann-dot wants to merge 5 commits into
mainfrom
dot-ai-langchain-google-gemini

Conversation

@ihoffmann-dot

Copy link
Copy Markdown
Member

Summary

Adds Google AI (Gemini API / AI Studio) as a supported provider under the identifier
google_ai — distinct from the existing vertex_ai, which reaches the same model
family through Google Cloud. This is the consumer-facing Gemini API: a single
AI Studio API key, no GCP project/location/service-account setup.

Full model-type coverage — the only provider besides OpenAI with all four:

  • Add langchain4j-google-ai-gemini dependency (version via langchain4j BOM)
  • Add GoogleAiGeminiModelProviderStrategy registered in LangChain4jModelFactory.STRATEGIES
  • Chat + streaming chat via GoogleAiGeminiChatModel / GoogleAiGeminiStreamingChatModel
  • Embeddings via GoogleAiEmbeddingModeldimensions maps to outputDimensionality
  • Image generation via GoogleAiGeminiImageModelsize maps to imageSize (1K/2K)
  • Add 11 unit tests in LangChain4jModelFactoryTest

Configuration

{
  "chat": {
    "provider": "google_ai",
    "model": "gemini-2.0-flash",
    "apiKey": "AIza...",
    "maxTokens": 4096,
    "temperature": 0.7
  },
  "embeddings": {
    "provider": "google_ai",
    "model": "gemini-embedding-001",
    "apiKey": "AIza...",
    "dimensions": 768
  },
  "image": {
    "provider": "google_ai",
    "model": "gemini-2.5-flash-image",
    "apiKey": "AIza...",
    "size": "1K"
  }
}

Notes

  • API key comes from Google AI Studio — no GCP project required.
  • size for image uses Gemini's format (1K, 2K), not OpenAI's 1024x1024.
  • maxRetries is not supported by the streaming chat model and is ignored with a warning (same behavior as the OpenAI provider).
  • endpoint optionally overrides the default base URL on all three model types.

Related Issue

This PR fixes #36134
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 1m 36s —— View job


Rollback Safety Analysis — ✅ Safe To Rollback

  • Read rollback-unsafe categories reference
  • Get full PR diff
  • Analyze diff against each unsafe category
  • Applied label: AI: Safe To Rollback

Analysis

The PR diff touches exactly 5 files:

File Change Type
dotCMS/pom.xml +5 lines — adds langchain4j-google-ai-gemini dependency
GoogleAiGeminiModelProviderStrategy.java New class — LangChain4J provider strategy
LangChain4jModelFactory.java Registers new strategy in the list
ProviderConfig.java Documentation/Javadoc only
LangChain4jModelFactoryTest.java +149 lines of unit tests

Checked against every unsafe category:

Category Verdict
C-1 Structural Data Model Change ✅ No DB schema changes, no runonce tasks
C-2 Elasticsearch Mapping Change ✅ No changes to ES mapping code or tasks
C-3 Content JSON Serialization Version Bump ✅ No changes to ImmutableContentlet or model version
C-4 DROP TABLE / DROP COLUMN ✅ No DDL drop statements
H-1 One-Way Data Migration ✅ No data transformation tasks
H-2 RENAME TABLE / RENAME COLUMN ✅ No renames
H-3 PK / Unique Constraint Restructuring ✅ No PK changes
H-4 New ContentType Field Type ✅ No new Field subtypes registered in FieldTypeAPI
H-5 Binary Storage Provider Change ✅ No storage provider changes
H-6 DROP PROCEDURE / DROP FUNCTION ✅ No stored procedure changes
H-7 NOT NULL Column Without Default ✅ No DDL changes at all
H-8 VTL Viewtool Contract Change ✅ No ViewTool implementations touched
M-1 Non-Broadening Column Type Change ✅ No column type changes
M-2 Push Publishing Bundle Format Change ✅ No bundler/handler changes
M-3 REST / GraphQL API Contract Change ✅ No REST endpoint or GraphQL schema changes
M-4 OSGi Plugin API Breakage ✅ No public interface changes in OSGi-exported packages

Conclusion: All changes are purely additive — a new Maven dependency, a new internal implementation class, one list registration, documentation updates, and unit tests. N-1 is completely unaffected: it does not reference google_ai as a provider, the new class is dead code to N-1, and no shared infrastructure was modified. This PR is safe to roll back.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Codex Review — openai.gpt-5.5

**[> [🟡 Medium] dotCMS/pom.xml:517 — New dependency is added directly to dotCMS/pom.xml without showing dependency management in bom/application/pom.xml. dotCMS convention requires dependency versions to be managed in the BOM; if this artifact is not already managed there, Maven builds will fail with a missing version.


Run: #27393353859 · tokens: in: 4253 · out: 597 (reasoning: 516) · total: 4850

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: dotCMS/pom.xml:535-540 — Adding langchain4j-google-ai-gemini dependency directly to dotCMS/pom.xml violates dotCMS convention; all third-party dependency versions must be declared in bom/application/pom.xml to ensure version consistency across modules. This risks version conflicts and undetermined behavior in production.
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:39apiKey() is passed directly from config to GoogleAiGeminiChatModel.builder().apiKey() without validation that it is not a blank string or null — but validate() only checks for non-blank, not for null. If config.apiKey() returns null, builder.apiKey(null) will throw NullPointerException at runtime. This is a silent crash in production.
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:58maxRetries is logged as ignored in streaming model, but not enforced by the builder — this creates a false expectation that retries are configurable. The parameter should be removed from config or explicitly excluded from builder to avoid misleading configuration.
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:97validate() uses ModelProviderStrategy.requireNonBlank() — but this method is not verified to exist or be accessible in the current codebase. Assumption: ModelProviderStrategy is a base class with this static method. What to verify: Confirm ModelProviderStrategy.requireNonBlank() is defined and public in dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/ModelProviderStrategy.java.
  • 🟡 Medium: dotCMS/src/test/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactoryTest.java:544-700 — Test coverage is complete for success paths, but no test verifies that timeout values are correctly converted to Duration (e.g., negative or zero values). Assumption: LangChain4J validates timeout internally. What to verify: Confirm GoogleAiGeminiChatModel.builder().timeout() throws on invalid values — if not, this is a silent misconfiguration risk.
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/ProviderConfig.java:53-62apiKey is documented as required, but no mention of security handling (e.g., encrypted storage, masking in logs). This is a design gap — API keys are sensitive. Assumption: dotCMS has a secrets management layer. What to verify: Confirm ProviderConfig is only populated via secure config sources (e.g., Vault, encrypted properties) and not from unsecured env vars or UI inputs.

Existing

  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactory.java:23 — The STRATEGIES list is static and unmodifiable — if a provider fails to initialize (e.g., due to missing key), the entire AI subsystem fails silently. This is a pre-existing systemic risk not fixed by this PR.

Resolved

  • dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactory.java:23 — Added GoogleAiGeminiModelProviderStrategy to strategies list — resolves missing provider registration.

Run: #28260103764 · tokens: in: 5045 · out: 1154 · total: 6199

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 Bedrock Review — qwen.qwen3-next-80b-a3b

New Issues

  • 🔴 Critical: dotCMS/pom.xml:535-540 — Adding langchain4j-google-ai-gemini dependency directly to dotCMS/pom.xml violates convention; versions must be declared in bom/application/pom.xml
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:39 — apiKey() may be null, causing NullPointerException when passed to GoogleAiGeminiChatModel.builder().apiKey()
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:58 — maxRetries is logged as ignored but still accepted by builder, creating misleading configuration
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:97 — ModelProviderStrategy.requireNonBlank() usage unverified — must confirm method exists and is accessible
  • 🟡 Medium: dotCMS/src/test/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactoryTest.java:544-700 — No test for invalid timeout values — assume LangChain4J validates, but must verify
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/ProviderConfig.java:53-62 — apiKey is sensitive but no security handling documented or enforced — assume secrets management exists, must verify

Existing

  • 🔴 Critical: dotCMS/pom.xml:535-540 — Adding langchain4j-google-ai-gemini dependency directly to dotCMS/pom.xml violates convention; versions must be declared in bom/application/pom.xml
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:39 — apiKey() may be null, causing NullPointerException when passed to GoogleAiGeminiChatModel.builder().apiKey()
  • 🟠 High: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:58 — maxRetries is logged as ignored but still accepted by builder, creating misleading configuration
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:97 — ModelProviderStrategy.requireNonBlank() usage unverified — must confirm method exists and is accessible
  • 🟡 Medium: dotCMS/src/test/java/com/dotcms/ai/client/langchain4j/LangChain4jModelFactoryTest.java:544-700 — No test for invalid timeout values — assume LangChain4J validates, but must verify
  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/ProviderConfig.java:53-62 — apiKey is sensitive but no security handling documented or enforced — assume secrets management exists, must verify

Resolved

  • dotCMS/src/main/java/com/dotcms/ai/client/langchain4j/GoogleAiGeminiModelProviderStrategy.java:97 — ModelProviderStrategy.requireNonBlank() usage is now present and validated in validate() method

Run: #28260157570 · tokens: in: 5739 · out: 1098 · total: 6837

@ihoffmann-dot ihoffmann-dot marked this pull request as ready for review June 26, 2026 19:36
final GoogleAiGeminiChatModel.GoogleAiGeminiChatModelBuilder builder = GoogleAiGeminiChatModel.builder()
.apiKey(config.apiKey())
.modelName(config.model());
if (config.endpoint() != null) builder.baseUrl(config.endpoint());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one single line if and no { } 🙄

@fabrizzio-dotCMS fabrizzio-dotCMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one minor nit

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 dotBot Review (Bedrock)

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

✅ No issues found after verification.


us.deepseek.r1-v1:0 · Run: #28266633073 · tokens: in: 23522 · out: 6225 · total: 29747 · calls: 7 · est. ~$0.065

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEATURE] dotAI: LangChain4J integration — Phase 2 (Google AI Gemini)

2 participants