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"