mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 09:39:48 +08:00
Reasoning models (Qwen, DeepSeek, etc.) emit chain-of-thought inside <think>...</think> blocks before the JSON payload. parse_json_response() did not account for this: a brace inside the reasoning was picked up by the raw_decode scan and returned instead of the real object, silently yielding wrong or empty data (e.g. empty BookEngine proposal fields). Strip <think> blocks only on the direct-parse failure path, so a valid JSON payload whose string values legitimately contain the substring '<think>' is preserved exactly. Also drop an unclosed leading <think> prelude up to the first JSON opener, and return the fallback when the response is reasoning-only with no payload. Fixes #673 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>