feat(py/plugins/google-genai): Support tuned Gemini endpoint models#5182
feat(py/plugins/google-genai): Support tuned Gemini endpoint models#5182
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for Vertex AI tuned Gemini endpoints to the Google GenAI plugin. It introduces helper functions to identify and resolve tuned endpoint names, ensuring short-form identifiers are correctly expanded to full resource paths for the SDK. The model resolution logic was updated to integrate these endpoints, and comprehensive tests were added. Feedback was provided to improve the robustness of the resource path validation by ensuring the presence of the location segment in fully qualified names.
| """ | ||
| if name.startswith('endpoints/'): | ||
| return True | ||
| return name.startswith('projects/') and '/endpoints/' in name |
There was a problem hiding this comment.
The check for fully qualified resource paths is slightly permissive. To align more strictly with Vertex AI resource naming conventions and avoid potential false positives, consider verifying the presence of the /locations/ segment as well.
| return name.startswith('projects/') and '/endpoints/' in name | |
| return name.startswith('projects/') and '/locations/' in name and '/endpoints/' in name |
Accepts Vertex AI tuned endpoints addressed either by the short form `endpoints/ID` or the full resource path `projects/PROJECT/locations/LOCATION/endpoints/ID`. - gemini.py gains is_tuned_gemini_name() and resolve_vertex_model_name() helpers; both generate_content call sites wrap the model name through the latter so the SDK receives a fully qualified path and skips its default publishers/google/models/ prefixing. - VertexAI._resolve_model routes tuned endpoint names through GeminiModel with the standard Gemini config schema and a sensible label. - Skip list_actions injection — tuned endpoints are private and not publicly listable. - Mirrors the Go PR #5178 design and the JS behaviour in js/plugins/google-genai/src/vertexai/client.ts. - Adds a unit test file covering both helpers and all dispatch paths.
e537e69 to
f3ea96e
Compare
Accepts Vertex AI tuned Gemini endpoints addressed either by the short form
endpoints/IDor the fully qualifiedprojects/PROJECT/locations/LOCATION/endpoints/ID.is_tuned_gemini_name()andresolve_vertex_model_name()helpers ingemini.pyhandle the classification and path expansion; bothgenerate_contentcall sites wrap the model name through the resolver so the SDK receives a fully qualified path and skips its defaultpublishers/google/models/prefix.VertexAI._resolve_modelroutes these names throughGeminiModel.Mirrors Go PR #5178 and the JS behaviour in
js/plugins/google-genai/src/vertexai/client.ts.Test plan
uv run pytest plugins/google-genai/test/test_tuned_gemini.py -v— 8 unit tests (classification + 5 resolver cases) pass.uv run pytest plugins/google-genai/test/ plugins/google-genai/tests/— all 241 existing tests still green.uv run ruff check/ruff format --checkclean.GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION, and a tuned endpoint, callai.generate(model='vertexai/endpoints/<id>', prompt=...)and confirm content returns.