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"})
|
||||
|
||||
@@ -142,6 +142,7 @@ class BrowserOnlyAppTests(unittest.TestCase):
|
||||
self.assertEqual(status, 200)
|
||||
self.assertTrue(body["ok"])
|
||||
self.assertEqual(http_json.call_args.args[0:2], ("POST", "https://api.deepseek.com/v1/chat/completions"))
|
||||
self.assertEqual(http_json.call_args.args[2]["thinking"], {"type": "disabled"})
|
||||
|
||||
def test_provider_errors_are_not_mislabelled_as_maps_errors(self):
|
||||
class CloudflareResponse:
|
||||
|
||||
Reference in New Issue
Block a user