Skip to content

Update Gemini adapter examples to use gemini-2.5-pro#138

Open
wachterjohannes wants to merge 1 commit into
0.4from
feature/update-gemini-examples-to-pro
Open

Update Gemini adapter examples to use gemini-2.5-pro#138
wachterjohannes wants to merge 1 commit into
0.4from
feature/update-gemini-examples-to-pro

Conversation

@wachterjohannes

@wachterjohannes wachterjohannes commented Nov 22, 2025

Copy link
Copy Markdown
Member
  • Update bootstrap.php to use models/gemini-2.5-pro instead of models/gemini-2.0-flash
  • Add list-models.php utility script to query available Gemini models from the API
  • Use latest stable Pro model (Gemini 2.5 Pro, released June 2025)
  • Gemini 3 Pro not yet available through standard API

Summary by CodeRabbit

  • New Features

    • Added new example demonstrating retrieval and display of available Google Gemini models with their capabilities and supported generation methods.
  • Chores

    • Updated Google Gemini model to the latest available version in example configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

- Update bootstrap.php to use models/gemini-2.5-pro instead of models/gemini-2.0-flash
- Add list-models.php utility script to query available Gemini models from the API
- Use latest stable Pro model (Gemini 2.5 Pro, released June 2025)
- Gemini 3 Pro not yet available through standard API
@coderabbitai

coderabbitai Bot commented Nov 22, 2025

Copy link
Copy Markdown

Walkthrough

Two updates to the Google Gemini adapter examples: upgrading the model version in bootstrap.php from gemini-2.0-flash to gemini-2.5-pro, and adding a new list-models.php example script that demonstrates retrieving and displaying available Gemini models from the Generative Language API.

Changes

Cohort / File(s) Summary
Model version update
packages/google-gemini-adapter/examples/bootstrap.php
Updated GoogleGeminiChatAdapter initialization to use gemini-2.5-pro instead of gemini-2.0-flash
New example script
packages/google-gemini-adapter/examples/list-models.php
Added new example demonstrating how to fetch and display available Gemini models via the Generative Language API, including environment variable loading, HTTP request handling, JSON parsing, and filtered output

Sequence Diagram

sequenceDiagram
    participant Script as list-models.php
    participant Env as Environment
    participant HTTP as HTTP Client
    participant API as Gemini API
    participant Output as Output

    Script->>Env: Load .env file
    Script->>Env: Read GOOGLE_GEMINI_API_KEY
    alt API key present
        Script->>HTTP: Get PSR-18 HTTP Client
        Script->>HTTP: Send GET request to models endpoint
        HTTP->>API: GET /v1beta/models?key={API_KEY}
        API-->>HTTP: JSON response with models array
        HTTP-->>Script: Response received
        Script->>Script: Decode JSON response
        Script->>Script: Iterate and filter models<br/>(generateContent method)
        Script->>Output: Print model details<br/>(name, displayName, description, methods)
    else API key missing
        Script->>Output: Throw RuntimeException
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • bootstrap.php: Single model name change is trivial; verify the new model name is correct and supported.
  • list-models.php: Straightforward new example script with standard patterns (environment loading, HTTP requests, JSON parsing); ensure error handling is appropriate and the API endpoint path is correct.

Poem

🐰 A flash becomes pro, the model takes flight,
New lists of companions now shining so bright,
The Gemini garden grows day by day,
With examples to guide us along the way! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: updating Gemini adapter examples to use gemini-2.5-pro, which aligns with both the bootstrap.php model update and the addition of the list-models.php example.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/update-gemini-examples-to-pro

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/google-gemini-adapter/examples/list-models.php (1)

26-31: Consider validating the HTTP response status.

The script sends the request but doesn't check if the response status is successful before parsing the body. While the JSON decode will throw on invalid data, validating the HTTP status code would provide clearer error messages for API failures.

Add status validation after line 31:

$request = new \Nyholm\Psr7\Request('GET', $url);
$response = $client->sendRequest($request);

+if ($response->getStatusCode() !== 200) {
+    throw new \RuntimeException("API request failed with status {$response->getStatusCode()}: {$response->getBody()}");
+}
+
$body = (string) $response->getBody();
packages/google-gemini-adapter/examples/bootstrap.php (1)

47-47: Consider renaming the variable for clarity.

The model gemini-2.5-pro is valid and correctly formatted with the "models/" prefix for the Generative Language API. However, the variable name $flashAdapter no longer matches the model type. For example code clarity, consider renaming it to $proAdapter or $geminiAdapter.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b63f87 and 374b433.

📒 Files selected for processing (2)
  • packages/google-gemini-adapter/examples/bootstrap.php (1 hunks)
  • packages/google-gemini-adapter/examples/list-models.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/examples/**

⚙️ CodeRabbit configuration file

**/examples/**: - Example code should be clear and educational

  • Comments explaining workflow are valuable
  • Docstrings not required

Files:

  • packages/google-gemini-adapter/examples/list-models.php
  • packages/google-gemini-adapter/examples/bootstrap.php
🧬 Code graph analysis (2)
packages/google-gemini-adapter/examples/list-models.php (1)
packages/fireworksai-adapter/src/Http/Psr18ClientDecorator.php (1)
  • sendRequest (27-40)
packages/google-gemini-adapter/examples/bootstrap.php (1)
packages/google-gemini-adapter/src/Chat/GoogleGeminiChatAdapter.php (1)
  • GoogleGeminiChatAdapter (39-207)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Qdrant Embeddings Store / PHP 8.2 / Dependencies highest / Lint true
  • GitHub Check: Elasticsearch Embeddings Store / PHP 8.2 / Dependencies highest / Lint true
  • GitHub Check: Elasticsearch Embeddings Store / PHP 8.2 / Dependencies lowest / Lint false
🔇 Additional comments (3)
packages/google-gemini-adapter/examples/list-models.php (3)

1-24: LGTM! Clean setup and validation.

The environment setup, dependency loading, and API key validation follow best practices for example code. The error message is clear and helpful.


33-34: LGTM! Proper JSON error handling.

Using JSON_THROW_ON_ERROR ensures invalid JSON responses cause clear exceptions rather than silent failures. Good practice for example code.


36-53: LGTM! Clear and educational output formatting.

The output logic is well-structured with:

  • Safe array access using null coalescing operators
  • Strict type checking in in_array()
  • Clear, formatted output that's helpful for understanding available models
  • Appropriate error fallback for debugging

This serves well as an educational example script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant