mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-29 00:17:44 +00:00
fix: fix a small bug in response_schema (#1043)
* fix: fix a small bug in response_schema * black fix
This commit is contained in:
@@ -575,12 +575,13 @@ class APIBackend(ABC):
|
||||
_, all_response = match.groups() if match else ("", all_response)
|
||||
|
||||
# 3) format checking
|
||||
if json_mode:
|
||||
if json_mode or json_target_type:
|
||||
parser = JSONParser()
|
||||
all_response = parser.parse(all_response)
|
||||
if json_target_type:
|
||||
# deepseek will enter this branch
|
||||
TypeAdapter(json_target_type).validate_json(all_response)
|
||||
|
||||
if json_target_type is not None:
|
||||
TypeAdapter(json_target_type).validate_json(all_response)
|
||||
if (response_format := kwargs.get("response_format")) is not None:
|
||||
if not isinstance(response_format, dict) and issubclass(response_format, BaseModel):
|
||||
# It may raise TypeError if initialization fails
|
||||
|
||||
@@ -95,7 +95,9 @@ class LiteLLMAPIBackend(APIBackend):
|
||||
"""
|
||||
if json_mode and supports_response_schema(model=LITELLM_SETTINGS.chat_model):
|
||||
kwargs["response_format"] = {"type": "json_object"}
|
||||
|
||||
elif not supports_response_schema(model=LITELLM_SETTINGS.chat_model) and "response_format" in kwargs:
|
||||
# Deepseek will enter this branch
|
||||
logger.warning(
|
||||
f"{LogColors.RED}Model {LITELLM_SETTINGS.chat_model} does not support response schema, ignoring response_format argument.{LogColors.END}",
|
||||
tag="llm_messages",
|
||||
|
||||
Reference in New Issue
Block a user