Vertex base url update#28145
Conversation
|
Size Change: +1.07 kB (0%) Total Size: 35.2 MB
ℹ️ View Unchanged
|
Summary of ChangesHello, 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 optimizes the Gemini CLI's integration with Vertex AI by introducing smarter default endpoint routing and more helpful, context-aware error messages. By targeting official Representative Endpoints based on the user's location, the client avoids legacy hostname issues. Additionally, the update provides clearer feedback when a model is missing in a specific region, guiding users to official documentation to resolve availability issues. Highlights
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 the 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 counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for Vertex AI Representative Endpoints (REP) in the US and EU regions when no base URL is provided, and improves error handling for ModelNotFoundError by displaying region-specific availability messages and documentation links. The review feedback suggests making the GOOGLE_CLOUD_LOCATION environment variable checks more robust by trimming and lowercasing the values to handle case-sensitivity and whitespace-only strings correctly.
|
📊 PR Size: size/M
|
Summary
This PR addresses two critical items for developers and users running Gemini CLI with Vertex AI:
GOOGLE_CLOUD_LOCATIONis set to'us'or'eu'respectively (and no explicitbaseUrlis set).ModelNotFoundError(404) under Vertex AI by displaying detailed region-specific messages and pointing users to the official Google Cloud supported locations documentation page.Details
1. Vertex AI Representative Endpoints (REP)
baseUrlconfigured, the client dynamically constructs default legacy hostnames (e.g.,'us-aiplatform.googleapis.com') instead of routing to the official REP endpoints.packages/core/src/core/contentGenerator.ts:VERTEX_AI_US_REP_ENDPOINT = 'https://aiplatform.us.rep.googleapis.com'VERTEX_AI_EU_REP_ENDPOINT = 'https://aiplatform.eu.rep.googleapis.com'createContentGenerator, we check theGOOGLE_CLOUD_LOCATIONenvironment variable and if noenvBaseUrlis present andconfig.authType === AuthType.USE_VERTEX_AI, we set thebaseUrlto the corresponding US or EU REP endpoint if the location matches.2. Region-Specific Model Availability Error Messaging
ModelNotFoundError.packages/cli/src/ui/hooks/useQuotaAndFallback.tsto capture this specific scenario:https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations.3. Unit Testing
should use US REP endpoint for Vertex AI when location is us and no baseUrl is providedandshould use EU REP endpoint for Vertex AI when location is eu and no baseUrl is providedinpackages/core/src/core/contentGenerator.test.ts.should handle ModelNotFoundError with Vertex AI by displaying region-specific availability message and documentation linkandshould handle ModelNotFoundError with Vertex AI and invalid model by displaying generic not found error messageinpackages/cli/src/ui/hooks/useQuotaAndFallback.test.ts.contentGenerator.test.tsto prevent leakage from any host machine's environment variables.How to Validate
Run unit tests across packages:
All 85 tests should pass successfully.
Local testing can be done via setting
for both a build including this change, and one without it to verify that gemini-3.5-flash models do not error with no set base vertex URL in this updated build.
Pre-Merge Checklist