From 045c51a6d09f32fb166790b84ee9f083529d49ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 05:35:36 +0000 Subject: [PATCH] Add enable_thinking option for chat_template_kwargs Co-authored-by: yeeyou <775190+yeeyou@users.noreply.github.com> --- README.md | 3 +++ openai_llm_node.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5b1cf5..b244b7c 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,9 @@ pip install requests pillow torch numpy - `auto`: 自动选择 - `low`: 低细节(更快,更便宜) - `high`: 高细节(更详细,更慢) +- **enable_thinking**: 是否启用思考模式(默认:关闭) + - 启用后会在请求中添加 `chat_template_kwargs: {"enable_thinking": true}` + - 适用于支持思考/推理模式的模型(如 QwQ、DeepSeek-R1 等,配合 vLLM 使用) ## 使用示例 diff --git a/openai_llm_node.py b/openai_llm_node.py index e7da75f..d51dca5 100644 --- a/openai_llm_node.py +++ b/openai_llm_node.py @@ -65,6 +65,9 @@ class OpenAICompatibleLLM: "image_detail": (["auto", "low", "high"], { "default": "auto" }), + "enable_thinking": ("BOOLEAN", { + "default": False + }), } } @@ -96,7 +99,7 @@ class OpenAICompatibleLLM: return f"data:image/png;base64,{img_base64}" def generate(self, prompt, endpoint, model, max_tokens, temperature, seed, seed_control, - image=None, api_key=None, image_detail="auto"): + image=None, api_key=None, image_detail="auto", enable_thinking=False): """ 调用 OpenAI 兼容的 API 生成响应 """ @@ -152,6 +155,9 @@ class OpenAICompatibleLLM: "seed": actual_seed } + if enable_thinking: + payload["chat_template_kwargs"] = {"enable_thinking": True} + # 设置请求头 headers = { "Content-Type": "application/json"