Studio: assert promoted fields on attribute path in test_extra_fields_accepted

This PR promoted frequency_penalty and seed from undeclared
chat-completion extras into explicit ChatCompletionRequest fields,
so they ride the attribute path now, not model_extra. The test
still asserted both via model_extra and failed on Linux Python
3.10-3.13 with 'assert None == 0.5'. response_format stays in
model_extra (still undeclared) so the extra='allow' contract is
covered by that branch.
This commit is contained in:
Daniel Han 2026-05-22 20:34:10 +00:00
commit eefe40a6bf

View file

@ -275,18 +275,19 @@ class TestChatCompletionRequestToolFields:
assert req.stop is None
def test_extra_fields_accepted(self):
# `frequency_penalty`, `seed`, `response_format` are not yet
# explicitly declared but must survive Pydantic parsing now that
# extra="allow" is set.
# ``response_format`` is still an undeclared OpenAI-side field;
# it must survive Pydantic parsing because extra="allow" is set.
# ``frequency_penalty`` and ``seed`` were promoted to explicit
# ChatCompletionRequest fields in the sampling-params PR, so
# they now ride the attribute path, not model_extra.
req = self._make(
frequency_penalty = 0.5,
seed = 42,
response_format = {"type": "json_object"},
)
# Extras land in model_extra
assert req.frequency_penalty == 0.5
assert req.seed == 42
assert req.model_extra is not None
assert req.model_extra.get("frequency_penalty") == 0.5
assert req.model_extra.get("seed") == 42
assert req.model_extra.get("response_format") == {"type": "json_object"}
def test_unsloth_extensions_still_work(self):