From 43bb639093009fe0995536d1fa33a915af773d38 Mon Sep 17 00:00:00 2001 From: Marco0300 Date: Thu, 10 Sep 2026 09:27:22 +0200 Subject: [PATCH] handle DeepSeek reasoning-only test responses --- api/server.py | 5 ++++- tests/test_app.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/server.py b/api/server.py index 18047be..a7bc01e 100644 --- a/api/server.py +++ b/api/server.py @@ -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"}) diff --git a/tests/test_app.py b/tests/test_app.py index 94db8b5..bd007b5 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -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: