Add enable_thinking option for chat_template_kwargs
Co-authored-by: yeeyou <775190+yeeyou@users.noreply.github.com>
This commit is contained in:
co-authored by
yeeyou
parent
7883311e85
commit
045c51a6d0
@@ -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
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user