support enable in the reasoning field to enable thingking for thinkin… (#9715)

This commit is contained in:
gongwei-130
2025-08-29 10:57:32 -07:00
committed by GitHub
parent 161e9dc51e
commit 3fd1431df2
2 changed files with 42 additions and 0 deletions

View File

@@ -460,6 +460,34 @@ class ChatCompletionRequest(BaseModel):
values["tool_choice"] = "auto"
return values
@model_validator(mode="before")
@classmethod
def normalize_reasoning_inputs(cls, values: Dict):
r = values.get("reasoning")
if r is None:
return values
if isinstance(r, dict):
effort = r.get("effort") or r.get("reasoning_effort")
if effort in {"low", "medium", "high"}:
values["reasoning_effort"] = effort
enabled = (
r.get("enabled")
if r.get("enabled") is not None
else r.get("enable", False)
)
if isinstance(enabled, str):
enabled = enabled.strip().lower() in {"1", "true", "yes", "y", "on"}
if enabled:
ctk = values.get("chat_template_kwargs")
if not isinstance(ctk, dict):
ctk = {}
ctk.setdefault("thinking", True)
values["chat_template_kwargs"] = ctk
return values
@model_validator(mode="before")
@classmethod
def set_json_schema(cls, values):