Repository navigation
fix(py/google-genai): omit default location in Vertex AI express mode - #7099
Closed
huangjeff5 wants to merge 1 commit into
Closed
huangjeff5 wants to merge 1 commit into
huangjeff5 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the VertexAI plugin to omit the default region when in express mode (i.e., when an api_key is provided and no project is set). It also ensures that calls to create_vertex_evaluators fallback to the default region if the location is unset, and adds a unit test to verify this behavior. I have no feedback to provide as there are no review comments.
Contributor
Author
|
Closing: migrated to standalone repository genkit-ai/genkit-python (PR #36): genkit-ai/genkit-python#36 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In Vertex AI Express mode (
VertexAI(api_key=...)without a GCP project),VertexAI.__init__previously defaultedself._locationto'us-central1'when no explicit location or environment variable was set. Passinglocation='us-central1'alongsideapi_key=...causes the Google GenAI client to target regional endpoints (https://us-central1-aiplatform.googleapis.com/) and generate resource URLs withprojects/None/locations/us-central1, causing Express Mode requests to fail.Mechanism
In
VertexAI.__init__, defaultself._locationtoconst.DEFAULT_REGIONonly when not in Express Mode (api_key and not self._project). When initializing Express Mode without an explicit location,self._locationisNone, allowinggenai.Clientto default to the global express endpoint (https://aiplatform.googleapis.com/).Verification
test_api_key_omits_default_locationinpackages/genkit-google-genai/tests/vertexai_location_test.pyverifying thatVertexAI(api_key='k')leaves location unset.pytest packages/genkit-google-genai(1518 passed).ruff check,ruff format, andpyrightclean.