mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(anthropic-responses): preserve nested strict setting
This commit is contained in:
parent
1e2645203b
commit
690656e2b3
2 changed files with 9 additions and 1 deletions
|
|
@ -520,7 +520,7 @@ class LiteLLMAnthropicToResponsesAPIAdapter:
|
|||
"type": "json_schema",
|
||||
"name": "structured_output",
|
||||
"schema": schema,
|
||||
"strict": bool(output_format.get("strict")),
|
||||
"strict": output_format.get("strict", False),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,14 @@ class TestOutputConfigStructuredOutput:
|
|||
assert fmt["strict"] is False
|
||||
assert fmt["name"] == "structured_output"
|
||||
|
||||
def test_output_config_format_explicit_strict_true_is_preserved(self):
|
||||
"""Nested output_config.format with explicit strict=True is preserved."""
|
||||
req = _make_request(
|
||||
output_config={"format": {"type": "json_schema", "schema": self._SCHEMA, "strict": True}}
|
||||
)
|
||||
kwargs = _ADAPTER.translate_request(req)
|
||||
assert kwargs["text"]["format"]["strict"] is True
|
||||
|
||||
def test_output_config_without_format_does_not_set_text(self):
|
||||
"""output_config with only non-format keys doesn't produce text.format."""
|
||||
req = _make_request(output_config={"effort": "high"})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue