CAMEL-24275: Native Google Gemini API for Camel JBang TUI - #25172
CAMEL-24275: Native Google Gemini API for Camel JBang TUI#25172atiaomar1978-hub wants to merge 5 commits into
Conversation
Post-review update (Bugbot + Grok)Pushed commit Update (@davsclaus —
|
davsclaus
left a comment
There was a problem hiding this comment.
Thanks for the contribution, @atiaomar1978-hub — solid work adding native Gemini support with comprehensive tests and thoughtful design choices (like restricting auto-detection to GEMINI_API_KEY to avoid hijacking unrelated GOOGLE_API_KEY setups).
A few issues to address before merge — the most important one is a mismatch between what the Doctor reports and what auto-detection actually does.
This review covers project rules, conventions, and code correctness visible from the diff. It does not replace specialized review tools (CodeRabbit, SonarCloud) or static analysis.
This review was generated by an AI agent (Claude Code on behalf of davsclaus) and may contain inaccuracies. Please verify all suggestions before applying.
Follow-up (@davsclaus review)Latest push: TUI messaging now matches Gemini auto-detection (Doctor no longer treats Review threads resolved; ready for another look when CI is green. AI-generated comment on behalf of atiaomar1978-hub |
davsclaus
left a comment
There was a problem hiding this comment.
Nice work adding native Gemini support, @atiaomar1978-hub — the implementation is clean, well-tested, and follows the existing patterns in LlmClient.
Minor observations (non-blocking)
-
applyDefaultModelasymmetry — the Gemini case checksDEFAULT_OLLAMA_MODEL.equals(model)to handle provider switching from Ollama, but the existing OpenAI and Anthropic cases do not have this guard. The Gemini approach is actually more robust; consider adding the same guard to the other providers in a follow-up. -
tryExplicitUrlhealth check for non-standard Gemini endpoints — the special-case bypass in theEXPLICIT_URL_HEALTH_CHECK_SUFFIXESloop works well forgenerativelanguage.googleapis.com, but the fallbacktryHealthCheck(url + "/v1beta/models")for non-standard endpoints runs without API key headers. Minor edge case since those users would need--api-type=geminianyway.
Everything else looks solid: API key via x-goog-api-key header (not URL query), GOOGLE_API_KEY scoped to explicit mode only, ToolCall record change is source-compatible, tests use AssertJ and package-private visibility per conventions, and documentation is properly updated.
This review was generated by an AI agent (Claude Code on behalf of davsclaus) and may contain inaccuracies. Please verify all suggestions before applying.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Latest push (
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 8 tested, 8 compile-only — current: 6 all testedMaveniverse Scalpel detected 16 affected modules (current approach: 6).
|
533eea6 to
9061093
Compare
gnodet
left a comment
There was a problem hiding this comment.
Well-structured PR that adds native Google Gemini API support following existing patterns for Anthropic/OpenAI. Prior review feedback from davsclaus was fully addressed.
Highlights:
- The
ToolCallrecord change (addingthoughtSignaturefield with backward-compatible 3-arg convenience constructor) is source-compatible with all existing callers. - Gemini API key resolution is well-designed: auto-detect only checks
GEMINI_API_KEY(avoiding hijacking unrelatedGOOGLE_API_KEYsetups), while explicit--api-type=geminiaccepts both. - Test coverage is strong: 11 tests in
LlmClientGeminiTestcovering URL normalization, model filtering, response parsing (including function calls and thoughtSignature round-trip), endpoint detection, and auth header verification. - All test conventions are followed: package-private classes/methods, AssertJ assertions, no
Thread.sleep(), proper@AfterEachcleanup.
Minor notes (non-blocking):
buildGeminiGenerateRequestForTestuses a*ForTestnaming pattern in production code — consider a more neutral name (e.g.,buildGeminiRequestWithContents) in a follow-up.- In
tryDetectGeminiAtExplicitUrl, when the endpoint is not a known Gemini domain,resolveGeminiApiKeyFromEnv()also acceptsGOOGLE_API_KEY, which could trigger a Gemini probe against a non-Gemini URL whenGOOGLE_API_KEYis set for unrelated GCP services. Risk is low since the probe requires a 200 response.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
|
the other PR was merged so this need rebase and fixing the code |
|
AI-generated comment on behalf of atiaomar1978-hub Rebased onto
Latest commit: rebased branch + compile fix. Tests: |
9061093 to
baf07a0
Compare
Wire ApiType.gemini to generativelanguage.googleapis.com with env key detection, model listing, tool calling, provider selector, and docs/tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Honor configured API keys, use x-goog-api-key headers, preserve function call id/thoughtSignature, limit GOOGLE_API_KEY to explicit gemini mode, and fix explicit URL health checks. Co-authored-by: Cursor <cursoragent@cursor.com>
…code Doctor and AiPanel mention GEMINI_API_KEY only for auto-detect; drop unused appendGeminiApiKey and geminiGenerateContentUrl key parameter. Co-authored-by: Cursor <cursoragent@cursor.com>
Probe /models with x-goog-api-key for non-google hosts instead of an unauthenticated /v1beta/models suffix; add AssertJ coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
Add tryHealthCheck(url, headers) delegating to the Azure-aware 3-arg overload so Gemini explicit URL detection compiles alongside Azure OpenAI. Co-authored-by: Cursor <cursoragent@cursor.com>
baf07a0 to
77702fa
Compare
|
Rebased onto latest `main` and resolved merge conflicts (AI-generated on behalf of atiaomar1978-hub). Conflicts resolved by keeping both Gemini support and the watsonx.ai integration from `main`:
Local tests: `LlmClientGeminiTest`, `LlmClientWatsonxTest`, `LlmClientAzureTest`, `AiProviderSelectorTest` (8/8 passed) Branch rebased and force-pushed: `77702fae2da` |
Summary
ApiType.geminitoLlmClientfor the Google Generative Language API (generativelanguage.googleapis.com), including env auto-detection (GEMINI_API_KEY;GOOGLE_API_KEYwhen--api-type=geminiis explicit), model listing, chat/generate with function calling (includingidandthoughtSignatureround-trip), and Gemini-aware URL health checks.x-goog-api-keyfor Gemini HTTP calls; generate URLs follow Google’s:generateContentpath form.GEMINI_API_KEYonly).--api-type=geminiin the JBang AI manual and 4.22 upgrade guide.Review follow-ups
425158b): configured API key, headers, thoughtSignature, auto-detect scope, URL health checks.d8e0e0f): Doctor/AiPanel aligned with auto-detect; removed dead query-param auth code.--urlGemini/proxy detection uses authenticated/modelsprobe (tryDetectGeminiAtExplicitUrl).Review status: @davsclaus approved on
d8e0e0f; follow-up commit addresses non-blocking explicit-URL note.Test plan
mvn test -pl dsl/camel-jbang/camel-jbang-core -Dtest=LlmClientGeminiTest,LlmClientListModelsTestmvn test -pl dsl/camel-jbang/camel-jbang-plugin-tui -Dtest=AiProviderSelectorTesthttps://issues.apache.org/jira/browse/CAMEL-24275
AI-generated PR description on behalf of atiaomar1978-hub