Repository navigation
fix(py): embedders always receive an options dict - #6668
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the embedder and evaluator options handling to return and pass an empty dictionary ({}) instead of None when no configuration is provided, ensuring consistent dictionary types. Review feedback suggests simplifying a ternary check in _evaluator.py using req.options or {} directly, and using the dictionary union operator | instead of unpacking in _aio.py for better readability.
apascal07
left a comment
There was a problem hiding this comment.
The in-repo plugins and samples still follow the None contract this PR removes: request.options or {} in google-genai _embedder.py (158, 203, 391) and openai _openai_plugin.py:572, and options: dict | None = None in samples/evaluators/src/main.py, genkit_evaluators/plugin.py and _evaluators/_evaluation.py.
894add5 to
890b095
Compare
|
@apascal07 on the plugins and samples: cleaned up in b238ee4. The google-genai Defaults from the declared |
|
@apascal07 re the review body: handled in b238ee4. google-genai |
Reverts evaluator changes from this PR because evaluators are excluded from the 1.0 cut and will be removed in #6947. Only embedders receive the options-dict guarantee here.
de3fd25 to
30862a5
Compare
|
Reverted evaluator-related changes from this PR. Evaluators are excluded from the 1.0 cut and will be removed in #6947, so this PR now strictly covers the embedder options dict guarantee. |
|
@apascal07 Reverted the evaluator changes from this PR since evaluators are excluded from the 1.0 cut and being removed in #6947. This PR now strictly scopes the empty-dict options guarantee to embedders. |
Embedders now always receive their options as a dict. When the caller leaves
configunset or passesconfig=None, the plugin gets{}, notNone. This reverts the sub-decision from #6569 that passedNonethrough, bringing embedders into alignment with models.Evaluators originally included in this PR were removed because evaluators are excluded from the 1.0 cut and removed in #6947.
Stack
None. (this PR)Decisions
request.configon models andrequest.optionson embedders are always a dict. Plugins can safely callreq.options.get(...)without defensivereq.options or {}guarding.EmbedRequest.optionsdefaults to{}and coercesNoneto{}during validation so direct Dev UI and CLI runs behave identically toai.embed().ai.embed(config=...)accepts mappings and BaseModels (which serialize to set fields), while invalid non-mapping inputs raiseINVALID_ARGUMENT.Tests
ai.embedandai.embed_manypass{}when config is omitted orNone.EmbedRequestwire parsing convertsoptions: nullto{}.