Skip to content

Conversation

@ehmm
Copy link

@ehmm ehmm commented Dec 4, 2025

This change adds vertexai, api_key, credentials, project, location, fields to the Gemini class in src/google/adk/models/google_llm.py. These fields are then passed to the google.genai.Client constructor in both _api_client and _live_api_client methods. This allows for more granular configuration of the Gemini client.

Problem:
Before this the only way to set Gemini model options was via env vars (quite messy)

Solution:
Add optional variables that can propagate to genai.Client

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • All unit tests pass locally.

3360 passed, 1 skipped, 2521 warnings in 94.33s (0:01:34)

Manual End-to-End (E2E) Tests:

This change adds `vertexai`, `api_key`, `credentials`, `project`, `location`, and `debug_config` fields to the `Gemini` class in `src/google/adk/models/google_llm.py`. These fields are then passed to the `google.genai.Client` constructor in both `_api_client` and `_live_api_client` methods. This allows for more granular configuration of the Gemini client.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ehmm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the configurability of the Gemini class by introducing dedicated parameters for various client settings. Instead of relying on environment variables, users can now directly specify options like API keys, credentials, and project details when initializing the Gemini client, leading to a cleaner and more explicit setup process.

Highlights

  • Enhanced Gemini Client Configuration: The Gemini class now includes new optional fields: vertexai, api_key, credentials, project, and location. These fields allow for direct configuration of the underlying google.genai.Client.
  • Direct Client Constructor Arguments: The newly added configuration fields are passed directly to the google.genai.Client constructor within both the _api_client and _live_api_client methods, providing more granular control over the Gemini client setup.
  • Reduced Reliance on Environment Variables: This change offers a more structured approach to configuring the Gemini client, moving away from the previous method of relying solely on environment variables, which was described as 'quite messy'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Dec 4, 2025
@adk-bot
Copy link
Collaborator

adk-bot commented Dec 4, 2025

Response from ADK Triaging Agent

Hello @ehmm, thank you for creating this PR!

Could you please provide logs or screenshots of your manual end-to-end tests? This will help reviewers to better understand and verify your changes. Thanks!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds several configuration options to the Gemini class, allowing for more granular control over the google.genai.Client initialization. The changes are straightforward and align with the goal of moving away from environment variables for configuration. My review includes a couple of suggestions to improve maintainability and fully implement the intended changes as described in the pull request description.

Comment on lines +91 to +95
vertexai: Optional[bool] = None
api_key: Optional[str] = None
credentials: Optional[google.auth.credentials.Credentials] = None
project: Optional[str] = None
location: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The pull request description mentions adding a debug_config field, but it appears to be missing here. To align with the PR's goal, you should add it. This will also require passing self.debug_config to the Client constructor in api_client and _live_api_client.

Suggested change
vertexai: Optional[bool] = None
api_key: Optional[str] = None
credentials: Optional[google.auth.credentials.Credentials] = None
project: Optional[str] = None
location: Optional[str] = None
vertexai: Optional[bool] = None
api_key: Optional[str] = None
credentials: Optional[google.auth.credentials.Credentials] = None
project: Optional[str] = None
location: Optional[str] = None
debug_config: Optional[types.DebugConfig] = None

Copy link
Author

Choose a reason for hiding this comment

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

Perferred at the end not to add DebugConfig as it is for internal use and probably not worth it will edit commit message

@ryanaiagent ryanaiagent self-assigned this Dec 4, 2025
@ryanaiagent ryanaiagent added models [Component] Issues related to model support and removed core [Component] This issue is related to the core interface and implementation labels Dec 4, 2025
@ryanaiagent
Copy link
Collaborator

Hi @ehmm , Thank you for your work on this pull request. We appreciate the effort you've invested.
Can you run autoformat.sh to fix the failing tests. Let us know once you are done so that we can proceed with the review.

@ryanaiagent ryanaiagent added the request clarification [Status] The maintainer need clarification or more information from the author label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants