Repository navigation
feat(py): typed family ref constructors on GoogleAI and VertexAI - #6104
Merged
huangjeff5 merged 3 commits intoAug 20, 2026
Merged
huangjeff5 merged 3 commits into
huangjeff5 merged 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces typed family reference constructors (such as gemini_model, gemma_model, and imagen_model) shared by the GoogleAI and VertexAI plugins, along with string literal types to support autocomplete. The feedback recommends ensuring backward compatibility with Python 3.9 by removing the TypeAlias imports and annotations, and suggests adding defensive type checking in _model_refs.py to prevent non-string inputs from being silently converted and accepted.
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 18, 2026 22:22
a3b7ded to
7b3fc70
Compare
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 19, 2026 16:54
7b3fc70 to
896eb16
Compare
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 19, 2026 21:52
c07cc84 to
e4ea4f0
Compare
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 19, 2026 22:01
e4ea4f0 to
c148b4e
Compare
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 19, 2026 22:23
d651eab to
eaab4ff
Compare
apascal07
approved these changes
Aug 20, 2026
One classmethod per config family (gemini_model, gemini_tts_model, gemini_image_model, gemma_model, imagen_model, embedding) because the method name is what picks the return type; Python cannot infer it from an open string. Constructors strip pasted prefixes (model/, models/, googleai/, vertexai/, ...) and stamp their own namespace, so a pasted cross-plugin name cannot smuggle its namespace into the ref. Ids whose action validates a different schema are refused with a hint at the right constructor; unknown ids stay usable through gemini_model so new releases work before the plugin learns their names. embedding() returns an EmbedderRef, never a ModelRef, and keeps Plugin.embedder as the Action resolve helper.
huangjeff5
force-pushed
the
feat/py-typed-family-refs-google-vertex
branch
from
August 20, 2026 19:11
eaab4ff to
e39aacc
Compare
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.
Summary
gemini_model,gemini_tts_model,gemini_image_model,gemma_model,imagen_model,embedding) so the method name is what picksModelRef[T]/EmbedderRef.model/,models/,googleai/,vertexai/, …) and stamp this plugin's namespace. A pasted cross-plugin name cannot smuggle its namespace into the ref. The specific prefixes to strip are defined within each plugin.gemini_model/embeddingso a new release works before this plugin learns its name.GoogleAI.embedding()/VertexAI.embedding()return anEmbedderRef. That is usable today:ai.embed(embedder=GoogleAI.embedding('gemini-embedding-001'), content=…). NamedembeddingsoPlugin.embedderstill resolves an Action.gemini_model()and the other generate constructors are typed factories.ai.generate(model=…)is stillstruntil feat(py): accept ModelRef on generate, prompt, agent, and Genkit constructor #6074. Samples stay on stringmodel=.Test plan
GoogleAI.gemini_model('gemini-2.5-flash').name == 'googleai/gemini-2.5-flash'and the Vertex twin stampsvertexai/vertexai/…,models/…,models/googleai/…all land on the constructor's namespacegemini_modelrefuses Veo / Lyria / Interactions / embedder / TTS / image / Gemma / Imagen / retired image idsGoogleAI.embedding('gemini-embedding-001')is anEmbedderRef, not aModelRefawait plugin.embedder('gemini-embedding-001')is still anActionKnownGemini/ TTS / image / Gemma / Imagen Literals match the import-time catalog (not idsresolve()writes later)