Repository navigation
refactor: consolidate extra_body merge logic into ModelOption.merge_extra_body - #1695
Conversation
…xtra_body Promote `_merge_extra_body` to the public `merge_extra_body` static method and make it the single canonical implementation used by all three merge paths. Changes: - model_options.py: rename _merge_extra_body → merge_extra_body; raise TypeError (naming the offending value and side) when chat_template_kwargs is not a dict; omit chat_template_kwargs from the output when the merged mapping is empty - openai.py: rewrite _merge_user_extra_body as two chained merge_extra_body calls (default < base < user); update __init__ call-site to public name - litellm.py: replace inline hand-rolled merge block with a single merge_extra_body call; update seed call-site to public name - test_model_options.py: replace silent-fallback tests with TypeError tests (base and overwrite side); add empty-both-sides-drops-key test; update no-mutation test to public name - test_options.py: add cross-path delegation tests for Scenarios A–D across all four paths (_via_helper, _via_merge_model_options, _via_openai, _via_litellm); convert Scenarios A–C to async to include the LiteLLM path Assisted-by: IBM Bob Signed-off-by: Vishal V <VishalV@ibm.com>
planetf1
left a comment
There was a problem hiding this comment.
LGTM. Consolidation does what it says — merge_extra_body is now the single implementation behind merge_model_options, LiteLLMBackend, and OpenAIBackend._merge_user_extra_body, and the new cross-path tests exercise all three call sites (not just the helper in isolation). Ran the test suite on this head: passing.
One non-blocking note: malformed chat_template_kwargs now raises TypeError instead of the old silent fallback — a real behaviour change on public ModelOption, worth a line in the PR description so it shows up in release notes, but no current caller depends on the old behaviour and the new failure mode matches the existing pattern in formatters/granite/base/util.py.
|
Hi @planetf1, Thanks for the review! I would like to bring to your attention that |
The The 0.9.0 docs will get created by the release process, and they should pick up changes you make - the api docs are constantly rebuild during dev too so https://docs.mellea.ai/next will give you a build of docs from main |
3f31b36
Pull Request
Issue
Fixes #1615
Description
Promote
_merge_extra_bodyto the publicmerge_extra_bodystatic method and make it the single canonical implementation used by all three merge paths. Malformedchat_template_kwargsnow raisesTypeErrorinstead of the old silent fallback.Changes:
Assisted-by: IBM Bob
Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.