mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-17 04:34:25 +00:00
test(deepseek): cover the response_schema-key extraction branch
Add coverage for the alternate top-level `response_schema` key path in _downgrade_json_schema_to_json_object (mirrors GroqChatConfig's extraction), bringing patch coverage on the change to 100%.
This commit is contained in:
parent
6e0077693a
commit
1217091048
1 changed files with 24 additions and 0 deletions
|
|
@ -153,6 +153,30 @@ def test_downgrade_json_schema_without_schema_body_still_downgrades():
|
|||
assert messages == original_messages
|
||||
|
||||
|
||||
def test_downgrade_reads_response_schema_key():
|
||||
"""Some callers pass the schema under a top-level `response_schema` key
|
||||
(mirrors GroqChatConfig's extraction); it is downgraded and injected too."""
|
||||
config = DeepSeekChatConfig()
|
||||
messages, optional_params = config._downgrade_json_schema_to_json_object(
|
||||
model="deepseek-chat",
|
||||
messages=[{"role": "user", "content": "Is the sky blue?"}],
|
||||
optional_params={
|
||||
"response_format": {
|
||||
"type": "json_schema",
|
||||
"response_schema": {
|
||||
"type": "object",
|
||||
"properties": {"answer": {"type": "string"}},
|
||||
"required": ["answer"],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
assert optional_params["response_format"] == {"type": "json_object"}
|
||||
assert "answer" in messages[-1]["content"]
|
||||
|
||||
|
||||
def test_downgrade_is_noop_for_json_object():
|
||||
config = DeepSeekChatConfig()
|
||||
original_messages = [{"role": "user", "content": "Is the sky blue?"}]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue