Update Gemini adapter examples to use gemini-2.5-pro#138
Update Gemini adapter examples to use gemini-2.5-pro#138wachterjohannes wants to merge 1 commit into
Conversation
- 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
WalkthroughTwo 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Example instruction:
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. Comment |
There was a problem hiding this comment.
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-prois valid and correctly formatted with the "models/" prefix for the Generative Language API. However, the variable name$flashAdapterno longer matches the model type. For example code clarity, consider renaming it to$proAdapteror$geminiAdapter.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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.phppackages/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_ERRORensures 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.
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.