Skip to content

fix(py)!: rename .embedding() to .embedder() and drop unused Plugin.model/embedder - #7049

Merged
huangjeff5 merged 1 commit into
mainfrom
fix/py-plugin-embedder-ref
Nov 4, 2026
Merged

huangjeff5 merged 1 commit into
mainfrom
fix/py-plugin-embedder-ref

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Renames GoogleAI.embedding() and VertexAI.embedding() to .embedder() (+12 / -41 lines in src/) so plugin ref constructors name the EmbedderRef handle rather than the vector output, matching ai.embed(embedder=...), JS (googleAI.embedder(...)), and Go (googlegenai.GoogleAIEmbedder(...)). Dropping the unused Plugin.model and Plugin.embedder methods on genkit.plugin_api.Plugin frees .embedder() on plugin subclasses without unbound-method collisions.

# --- BEFORE ---
from genkit_google_genai import GoogleAI

# 1. Calling .embedder() hit an unbound instance method on the Plugin base class
GoogleAI.embedder('gemini-embedding-001')
# => TypeError: Plugin.embedder() missing 1 required positional argument: 'name'

# 2. Callers had to call .embedding() to construct an EmbedderRef
embedder = GoogleAI.embedding('gemini-embedding-001')  # => EmbedderRef[EmbeddingConfig]
embeddings = await ai.embed(embedder=embedder, content='Smoked salmon tartine')

# --- AFTER ---
from genkit_google_genai import GoogleAI

# 1. .embedder() constructs an EmbedderRef on both the plugin class and instances
embedder = GoogleAI.embedder('gemini-embedding-001')
# => EmbedderRef[EmbeddingConfig], name='googleai/gemini-embedding-001'

# 2. Matches ai.embed(embedder=...) and separates the handle from returned vectors
embeddings = await ai.embed(embedder=embedder, content='Smoked salmon tartine')
print(len(embeddings[0].embedding))
# => 3072

Main Changes

  • Removed unused Plugin.model and Plugin.embedder base methods: Previously, genkit.plugin_api.Plugin carried async def model(self, name) and async def embedder(self, name) wrappers that Registry never called (it invokes await plugin.resolve(kind, local) directly). Because Python resolves SubPlugin.embedder('id') to the unbound base instance method (self='id'), those dead methods blocked plugins from defining @classmethod def embedder(...) -> EmbedderRef. Removing them frees .model and .embedder for typed ref constructors across all plugins.
  • Renamed GoogleAI.embedding and VertexAI.embedding to .embedder: feat(py): typed family ref constructors on GoogleAI and VertexAI #6104 originally picked .embedding() only to avoid shadowing Plugin.embedder, leaving the constructor named after the vector output (Embedding) rather than EmbedderRef. With Plugin.embedder removed, renaming to .embedder() before 1.0 aligns Python with ai.embed(embedder=...), JS, and Go.

Breaking

  • GoogleAI.embedding(...) and VertexAI.embedding(...) (added in v0.11.0 via feat(py): typed family ref constructors on GoogleAI and VertexAI #6104) are renamed to GoogleAI.embedder(...) and VertexAI.embedder(...).
  • Unused Plugin.model(name) and Plugin.embedder(name) on genkit.plugin_api.Plugin are removed; call await plugin.resolve(ActionKind.MODEL, name) or await plugin.resolve(ActionKind.EMBEDDER, name) when testing a plugin directly.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request renames the embedding method to embedder across the Google GenAI plugin to align with the naming conventions of other reference constructors. Additionally, it removes the model and embedder helper methods from the base Plugin class in the core package to prevent naming collisions with class-level reference constructors, updating the corresponding unit tests to reflect these changes. I have no further feedback to provide as there are no review comments to evaluate.

@huangjeff5
huangjeff5 added this pull request to stack #7050 November 3, 2026 17:38
@huangjeff5
huangjeff5 requested a review from pavelgj November 3, 2026 20:22
@huangjeff5 huangjeff5 changed the title fix(py)!: drop unused Plugin.model/embedder and rename .embedding() to .embedder() fix(py)!: rename .embedding() to .embedder() and drop unused Plugin.model/embedder Nov 4, 2026

@pavelgj pavelgj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@huangjeff5
huangjeff5 force-pushed the fix/py-plugin-embedder-ref branch from 6f8da62 to dc7b509 Compare November 4, 2026 20:13
@huangjeff5
huangjeff5 enabled stacked auto-merge (squash) November 4, 2026 20:13
@huangjeff5
huangjeff5 merged commit d083b4f into main Nov 4, 2026
24 checks passed
@huangjeff5
huangjeff5 deleted the fix/py-plugin-embedder-ref branch November 4, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants