handle DeepSeek reasoning-only test responses
This commit is contained in:
+4
-1
@@ -3877,7 +3877,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if ai_requires_api_key(runtime["provider"]) and not runtime["api_key"]:
|
||||
return self.send_json(400, {"error": "ai_provider_api_key_required"})
|
||||
headers = {"Authorization": "Bearer " + runtime["api_key"]} if runtime["api_key"] else {}
|
||||
result = http_json("POST", runtime["base_url"] + "/chat/completions", {"model": runtime["model"], "temperature": 0, "max_tokens": 8, "messages": [{"role": "user", "content": "Reply with exactly OK."}]}, headers=headers, timeout=30, error_prefix="ai")
|
||||
test_payload = {"model": runtime["model"], "temperature": 0, "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with exactly OK."}]}
|
||||
if runtime["provider"] == "deepseek":
|
||||
test_payload["thinking"] = {"type": "disabled"}
|
||||
result = http_json("POST", runtime["base_url"] + "/chat/completions", test_payload, headers=headers, timeout=30, error_prefix="ai")
|
||||
content = (((result.get("choices") or [{}])[0].get("message") or {}).get("content") or "") if isinstance(result, dict) else ""
|
||||
if not str(content).strip():
|
||||
return self.send_json(502, {"error": "ai_empty_response"})
|
||||
|
||||
Reference in New Issue
Block a user