Skip to content

feat(py): add ModelConfigDict for config={...} autocomplete - #5987

Closed
jeffdh5 wants to merge 7 commits into
genkit-ai:jh-model-ref-generatefrom
jeffdh5:jh-model-config-dict
Closed

jeffdh5 wants to merge 7 commits into
genkit-ai:jh-model-ref-generatefrom
jeffdh5:jh-model-config-dict

Conversation

@jeffdh5

@jeffdh5 jeffdh5 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add hand-written ModelConfigDict TypedDict for common generation knobs (temperature, max_output_tokens, …).
  • Swap app-facing config= unions on generate / generate_stream / define_prompt / generate_operation / define_agent from ModelConfig → ModelConfigDict, keeping Mapping[str, Any] as the escape hatch for provider-specific keys.
  • Export ModelConfigDict from genkit and genkit.model. ModelConfig (Pydantic) stays for plugins/runtime.
  • Update samples/tests that pass non-common keys so they go through a plain dict[str, Any] (ty rejects unknown keys on inline TypedDict literals).

Stacked on #5977 (jh-model-ref-generate).

Test plan

  • Fast CI preflight (lint/type + pytest 3.12)
  • test_model_config_dict_accepts_common_knobs
  • Confirm IDE autocomplete on config={'temperature': ...}
  • Confirm provider-specific configs still work via dict[str, Any] / Mapping

Swap app-facing config unions from ModelConfig to ModelConfigDict so
dict literals get common-knob autocomplete, while Mapping remains the
escape hatch for provider-specific keys.

@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 introduces ModelConfigDict, a new TypedDict representing common configuration options for models to enable better autocomplete support. It updates several functions and agents to accept this new dictionary type. The reviewer's feedback focuses on maintaining type flexibility: they recommend using Sequence[str] instead of list[str] for stop_sequences in ModelConfigDict, and advise against replacing Mapping[str, Any] with dict[str, Any] in function signatures to prevent type-checking regressions for custom mapping types.

huangjeff5 and others added 6 commits August 7, 2026 13:22
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants