Repository navigation
fix(py): resolve_model falls back to background models so generate_operation can find them - #6023
huangjeff5 wants to merge 3 commits into
Conversation
…eration can find them
There was a problem hiding this comment.
Code Review
This pull request updates generate_operation to resolve models using resolve_model and enhances resolve_model to fall back to ActionKind.BACKGROUND_MODEL if a standard model is not found. A unit test was also added to verify this fallback behavior. The review feedback suggests updating the return type signature of resolve_model to include Operation to ensure type safety, since background-only models return an Operation rather than a ModelResponse.
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the registry's 'resolve_model' method to fall back to background-only models (registered under 'ActionKind.BACKGROUND_MODEL') when a foreground model is not found, and updates its return type to include 'Operation'. Additionally, 'generate_operation' is updated to use 'resolve_model', and a unit test is added to verify this fallback behavior. There are no review comments, so I have no feedback to provide.
Product Context & Motivation
Genkit Python provides
generate_operation()to trigger asynchronous long-running generation tasks (such as Veo video generation or Deep Research). Previously,Registry.resolve_model()only looked up models registered under the standardActionKind.MODELnamespace. Consequently, background-only models registered underActionKind.BACKGROUND_MODELcould not be resolved bygenerate_operation(), causing model lookup errors.This PR fixes model resolution by enabling
resolve_modelto fall back toBACKGROUND_MODELwhen a model is not found in the foregroundMODELregistry.Key Changes
Registry.resolve_model()ingenkit._core._registryto fall back toActionKind.BACKGROUND_MODELwhen standard lookup returnsNone.Genkit.generate_operation()ingenkit._ai._aioto callresolve_model(), ensuring background models are correctly discovered.registry_test.pycovering background model resolution.Behavioral Nuance & Safety
MODELactions retain precedence: if a model exists in both namespaces, the foreground model is returned first.pytest py/packages/genkit/tests/genkit/core/registry_test.py(20 passed).