feat(go/plugins/googlegenai): Support tuned Gemini endpoint models#5178
feat(go/plugins/googlegenai): Support tuned Gemini endpoint models#5178cabljac wants to merge 1 commit into
Conversation
Accept Vertex AI tuned endpoints addressed either by the short form `endpoints/ID` or the full resource path `projects/PROJECT/locations/LOCATION/endpoints/ID`. ClassifyModel now routes these names to ModelTypeGemini, and a new resolveVertexModelName helper expands the short form to the full path before the google.golang.org/genai SDK transforms it, avoiding the SDK's default `publishers/google/models/` prefix that only applies to first-party models. VertexAI.DefineModel also accepts tuned endpoint names with a nil options argument, falling back to the default Gemini capability set. Adds unit tests for ClassifyModel and isTunedGeminiName, and a live subtest in vertexai_live_test.go gated by GENKIT_VERTEX_TUNED_ENDPOINT. Mirrors the JS behaviour in js/plugins/google-genai/src/vertexai/client.ts.
There was a problem hiding this comment.
Code Review
This pull request introduces support for Vertex AI tuned Gemini endpoints, allowing them to be addressed via short-form or full resource paths. Key changes include the addition of a name resolution helper, updates to model classification logic, and modifications to the model definition process to accommodate these dynamic endpoints. A critical feedback point identifies that tuned endpoints, which are not in the static model list, would receive empty model options; a suggestion was provided to use default Gemini options instead to ensure proper capability support.
| if isTunedGeminiName(name) { | ||
| defaults := GetModelOptions(name, vertexAIProvider) | ||
| opts = &defaults |
There was a problem hiding this comment.
Calling GetModelOptions with the tuned endpoint name (e.g., endpoints/ID) will likely return an empty ai.ModelOptions struct because tuned endpoints are not in the static list of known models. This results in a model with nil Supports, which can cause issues with Genkit features that validate model capabilities (like tool calling). Since tuned Gemini models share the same capabilities as base Gemini models, consider using a known Gemini model name to retrieve the default options.
| if isTunedGeminiName(name) { | |
| defaults := GetModelOptions(name, vertexAIProvider) | |
| opts = &defaults | |
| if isTunedGeminiName(name) { | |
| // Tuned models are not in the static list, so we use default Gemini options. | |
| defaults := GetModelOptions("gemini-1.5-flash", vertexAIProvider) | |
| opts = &defaults | |
| } else { |
There was a problem hiding this comment.
Traced this and the flow is fine — tuned endpoints get the full Gemini Supports, not nil. Path:
isTunedGeminiName("endpoints/ID")returns true (model_type.go:52).ClassifyModelreturnsModelTypeGeminivia the tuned fall-through at model_type.go:38–42.GetModelOptions(models.go:275–280) doesn't find the tuned name insupportedGeminiModels, so it falls back todefaultGeminiOpts, which has fullSupports(Multimodal).
No nil Supports at the call site. go build / go vet clean and CI is green.
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.
Accepts Vertex AI tuned Gemini endpoints addressed either by the short form
endpoints/IDor the full resource pathprojects/PROJECT/locations/LOCATION/endpoints/ID.ClassifyModelnow routes these names toModelTypeGemini, and a newresolveVertexModelNamehelper expands the short form to the full path before thegoogle.golang.org/genaiSDK transforms it — avoiding the SDK's defaultpublishers/google/models/prefix, which only applies to first-party models.VertexAI.DefineModelalso accepts tuned endpoint names with aniloptions argument and falls back to the default Gemini capability set.Mirrors
js/plugins/google-genai/src/vertexai/client.ts.Testing