mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
type_check_gate: keep the response_format check at its baseline count
The guard read `value.get("type")` inline, where `value` arrives as `object` and
`isinstance(value, Mapping)` narrows it to a bare `Mapping`, so `get()` came
back partially unknown and put the file one `reportUnknownMemberType` over its
merge-base ceiling.
Extracting it into `_is_supported_response_format` puts the narrowing on one
`object`-typed local, so the single unavoidable suppression sits there instead
of on the branch. Checked against the original expression over a json_schema
with a schema, text, an empty dict, json_object, a bogus type, a string, and
None, and the results match in every case
This commit is contained in:
parent
b165a3f392
commit
f2d4306433
1 changed files with 8 additions and 1 deletions
|
|
@ -52,6 +52,13 @@ class GigaChatError(BaseLLMException):
|
|||
"""GigaChat API error."""
|
||||
|
||||
|
||||
def _is_supported_response_format(value: object) -> bool:
|
||||
if not isinstance(value, Mapping):
|
||||
return False
|
||||
response_format_type: Final = value.get("type") # pyright: ignore[reportUnknownMemberType] # bare Mapping
|
||||
return response_format_type in (None, "text", "json_schema")
|
||||
|
||||
|
||||
class GigaChatConfig(BaseConfig):
|
||||
"""
|
||||
Configuration class for GigaChat API.
|
||||
|
|
@ -209,7 +216,7 @@ class GigaChatConfig(BaseConfig):
|
|||
]
|
||||
optional_params["function_call"] = {"name": schema_name}
|
||||
optional_params["_structured_output"] = True
|
||||
elif not (isinstance(value, Mapping) and (value.get("type") in (None, "text", "json_schema"))):
|
||||
elif not _is_supported_response_format(value):
|
||||
from litellm.utils import UnsupportedParamsError
|
||||
|
||||
if litellm.drop_params is not True and drop_params is not True:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue