Spaces:
Running
Running
Upload backend.py with huggingface_hub
Browse files- backend.py +7 -1
backend.py
CHANGED
|
@@ -44,6 +44,9 @@ def get_groq_client() -> Groq:
|
|
| 44 |
return Groq(api_key=os.environ.get("GROQ_API_KEY_OSS"))
|
| 45 |
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
# ---------------------------------------------------------------------------
|
| 48 |
# Prompts
|
| 49 |
# ---------------------------------------------------------------------------
|
|
@@ -225,8 +228,11 @@ def call_model_a(clinical_text: str) -> ModelResult:
|
|
| 225 |
{"role": "user", "content": ERROR_CHECK_USER_PROMPT.format(clinical_text=clinical_text)},
|
| 226 |
],
|
| 227 |
max_tokens=4096,
|
|
|
|
| 228 |
)
|
| 229 |
-
raw = response.choices[0].message.content
|
|
|
|
|
|
|
| 230 |
return _parse_to_result("DeepSeek Reasoner", raw, time.time() - start)
|
| 231 |
except Exception as exc:
|
| 232 |
return ModelResult(
|
|
|
|
| 44 |
return Groq(api_key=os.environ.get("GROQ_API_KEY_OSS"))
|
| 45 |
|
| 46 |
|
| 47 |
+
DEEPSEEK_TIMEOUT_SECONDS = 120
|
| 48 |
+
|
| 49 |
+
|
| 50 |
# ---------------------------------------------------------------------------
|
| 51 |
# Prompts
|
| 52 |
# ---------------------------------------------------------------------------
|
|
|
|
| 228 |
{"role": "user", "content": ERROR_CHECK_USER_PROMPT.format(clinical_text=clinical_text)},
|
| 229 |
],
|
| 230 |
max_tokens=4096,
|
| 231 |
+
timeout=DEEPSEEK_TIMEOUT_SECONDS,
|
| 232 |
)
|
| 233 |
+
raw = response.choices[0].message.content or ""
|
| 234 |
+
if not raw.strip():
|
| 235 |
+
raise ValueError("DeepSeek returned an empty response body.")
|
| 236 |
return _parse_to_result("DeepSeek Reasoner", raw, time.time() - start)
|
| 237 |
except Exception as exc:
|
| 238 |
return ModelResult(
|