Skip to content

feat(py/plugins/google-genai): Support tuned Gemini endpoint models#5182

Draft
cabljac wants to merge 1 commit intomainfrom
feat/py-vertexai-tuned-gemini
Draft

feat(py/plugins/google-genai): Support tuned Gemini endpoint models#5182
cabljac wants to merge 1 commit intomainfrom
feat/py-vertexai-tuned-gemini

Conversation

@cabljac
Copy link
Copy Markdown
Contributor

@cabljac cabljac commented Apr 23, 2026

Accepts Vertex AI tuned Gemini endpoints addressed either by the short form endpoints/ID or the fully qualified projects/PROJECT/locations/LOCATION/endpoints/ID.

is_tuned_gemini_name() and resolve_vertex_model_name() helpers in gemini.py handle the classification and path expansion; both generate_content call sites wrap the model name through the resolver so the SDK receives a fully qualified path and skips its default publishers/google/models/ prefix. VertexAI._resolve_model routes these names through GeminiModel.

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 --check clean.
  • Live (optional): with GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, and a tuned endpoint, call ai.generate(model='vertexai/endpoints/<id>', prompt=...) and confirm content returns.

Copy link
Copy Markdown
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 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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.
@cabljac cabljac force-pushed the feat/py-vertexai-tuned-gemini branch from e537e69 to f3ea96e Compare April 23, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant