fix: vLLM structured output missing thinking-control extra_body

This commit is contained in:
Woody 2026-04-29 21:01:10 +08:00
parent 16de8394aa
commit fc6b5463b5
1 changed files with 6 additions and 1 deletions

View File

@ -146,11 +146,16 @@ class LLMClient:
step_name, prompt_preview, json.dumps(schema)[:300], step_name, prompt_preview, json.dumps(schema)[:300],
) )
# Merge thinking-control params so vLLM structured calls
# also respect enable_thinking/vllm_engine config (was missing).
body = self._build_extra_body()
# Try the new unified format first, then legacy guided_json # Try the new unified format first, then legacy guided_json
for fmt_name, extra in [ for fmt_name, base_extra in [
("structured_outputs", {"structured_outputs": {"json": schema}}), ("structured_outputs", {"structured_outputs": {"json": schema}}),
("guided_json", {"guided_json": schema}), ("guided_json", {"guided_json": schema}),
]: ]:
extra = {**base_extra, **body}
try: try:
self.logger.info("[%s] vLLM structured: trying format=%s extra=%s", step_name, fmt_name, extra) self.logger.info("[%s] vLLM structured: trying format=%s extra=%s", step_name, fmt_name, extra)
response = await self._client.chat.completions.create( response = await self._client.chat.completions.create(