-
Notifications
You must be signed in to change notification settings - Fork 380
feat: Make LLM model configurable via MODEL env var #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Make LLM model configurable via MODEL env var #160
Conversation
Replace all hardcoded "gemini-2.5-flash" model strings with
os.environ.get("MODEL", "gemini-2.5-flash") so users can switch
models without editing source code. Also generalize "Gemini" references
in error messages to "LLM" for consistency.
Closes google-agentic-commerce#75
Summary of ChangesHello @Ayush10, 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 introduces a significant improvement in the application's flexibility by making the underlying Large Language Model (LLM) configurable through an environment variable. This change eliminates the need to modify source code to switch between different LLM models, streamlining development and deployment workflows. It also refines error messages to be more generic, aligning with the goal of supporting various LLM providers. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 introduces a great improvement by making the LLM model configurable through an environment variable, which enhances flexibility. The changes are well-implemented by replacing hardcoded model strings and generalizing error messages. My main feedback is to address the code duplication introduced by calling os.environ.get() in multiple files. I've suggested centralizing this logic into a single constant to improve maintainability, following the Don't Repeat Yourself (DRY) principle. I've left comments in all the affected files with this suggestion.
|
|
||
| response = self._client.models.generate_content( | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid repeating os.environ.get("MODEL", ...) across multiple files, consider defining it as a constant in a shared module, for example in common/system_utils.py:
# In common/system_utils.py
import os
LLM_MODEL = os.environ.get("MODEL", "gemini-2.5-flash")Then you can import and use this constant here and in the other 5 files where the model is specified. This improves maintainability by centralizing the configuration and allows removing the import os statement from files where it's no longer needed.
|
|
||
| llm_response = llm_client.models.generate_content( | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| root_agent = RetryingLlmAgent( | ||
| max_retries=5, | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| payment_method_collector = RetryingLlmAgent( | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| shipping_address_collector = RetryingLlmAgent( | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| shopper = RetryingLlmAgent( | ||
| model="gemini-2.5-flash", | ||
| model=os.environ.get("MODEL", "gemini-2.5-flash"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move os.environ.get("MODEL", "gemini-2.5-flash") into a single
LLM_MODEL constant in common/system_utils.py and import it across
all 6 files that reference it. Remove unused import os where applicable.
Summary
"gemini-2.5-flash"model strings withos.environ.get("MODEL", "gemini-2.5-flash"), allowing users to configure the model without editing source code.MODELis not set.Closes #75
Usage
Affected files
samples/python/src/roles/shopping_agent/agent.pysamples/python/src/roles/shopping_agent/subagents/shopper/agent.pysamples/python/src/roles/shopping_agent/subagents/shipping_address_collector/agent.pysamples/python/src/roles/shopping_agent/subagents/payment_method_collector/agent.pysamples/python/src/roles/merchant_agent/sub_agents/catalog_agent.pysamples/python/src/common/function_call_resolver.pysamples/python/src/common/retrying_llm_agent.pyTest plan
MODELset) — should behave identically to beforeMODEL=gemini-2.5-pro— should use the specified modelsamples/python/src/