Merge pull request #3 from yeeyou/copilot/add-enable-thinking-option

Add `enable_thinking` toggle for vLLM chat template kwargs
This commit is contained in:
yeeyou
2026-02-26 13:49:02 +08:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+3
View File
@@ -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 使用)
## 使用示例
+7 -1
View File
@@ -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"