Repository navigation
feat(py): accept ModelRef on generate, prompt, agent, and Genkit constructor - #6074
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for ModelRef across various core interfaces including generate, generate_stream, define_prompt, define_agent, and generate_operation. It adds a new helper resolve_call_model to handle model name resolution and configuration merging, alongside comprehensive unit tests. The review feedback highlights two key improvement opportunities: first, stripping None values from Mapping configurations when resolving string models to prevent validation errors in plugins; and second, removing a redundant 'resume': resume update in render_prompt_config_for_executable_call since PromptConfig does not define a resume field.
699b502 to
0ef598b
Compare
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for ModelRef and improved configuration merging across Genkit's Python SDK, specifically within agents, prompts, generation, and operations. It adds the resolve_call_model helper to handle model name resolution and configuration merging for ModelRef instances while preserving the original configuration objects for string-based models. Type annotations have been updated to accommodate these changes, and comprehensive unit tests have been added to verify the new behavior. No review comments were provided, so there is no additional feedback to provide.
c312a3d to
19964a9
Compare
db87e49 to
7be9ecf
Compare
7bf5459 to
dd431a4
Compare
dd431a4 to
aef3202
Compare
aef3202 to
354d2f6
Compare
b904e2f to
2bb35ef
Compare
de76436 to
5442b96
Compare
Support passing ModelRef across generate, generate_stream, generate_operation, define_prompt, and define_agent surfaces, merging model defaults with call-time configuration. Includes end-to-end tests for ModelRef resolution, config merging, explicit None clearing, unknown key pass-through, version override, and covariance verification for ModelRef[BaseModel].
5442b96 to
c765b66
Compare
Product
One
model=slot, two shapes — a name or aModelRef— on every surface:flashis a wire name plus defaults. A string is just the name. Same slot onGenkit(),generate,generate_stream,generate_operation,define_prompt, and agents.The merge lives in #6015. This PR opens the slots and pins the generate-level cases that layer was built for.
What generate has to survive
ref.versionis copied intoconfig.versionas the lowest layer. Overlaying temperature does not drop it.ref.config.versionbeats the constructorversion=field.The same overlay runs on the constructor default (
Genkit(model=flash)+ camel call dict) and on prompts (joke(config={'maxOutputTokens': 5})).Also
ExecutablePrompt merges defined config with per-call config using exclude_unset (same as generate): untouched fields cannot clobber defaults; an explicit
Noneclears.generate_operation()accepts a ModelRef and uses the same merge. Looking up a background model (BACKGROUND_MODEL, e.g. Veo) is #5854.What this does not fix
ModelRequest(config=dict)still rehydrates as genericModelConfig. That's feat(py): Make ModelRequest generic #5986.model=there is no schema, so nothing folds — dict keys pass through as written.