Spaces:
Sleeping
Sleeping
Fix ZeroGPU: wrap handler with @spaces.GPU
Browse files
app.py
CHANGED
|
@@ -9,6 +9,8 @@ structured fallback built from CVSS/CWE fields.
|
|
| 9 |
|
| 10 |
from __future__ import annotations
|
| 11 |
|
|
|
|
|
|
|
| 12 |
import json
|
| 13 |
import os
|
| 14 |
import re
|
|
@@ -278,7 +280,7 @@ def fallback_report(ctx: dict[str, Any]) -> str:
|
|
| 278 |
return "\n".join(lines)
|
| 279 |
|
| 280 |
|
| 281 |
-
def
|
| 282 |
cve_input = (cve_input or "").strip()
|
| 283 |
raw_description = (raw_description or "").strip()
|
| 284 |
cve_id = parse_cve_id(cve_input) or parse_cve_id(raw_description)
|
|
@@ -323,6 +325,12 @@ def explain(cve_input: str, raw_description: str, use_llm: bool):
|
|
| 323 |
return risk_md, header + report, json_out
|
| 324 |
|
| 325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
EXAMPLES = [
|
| 327 |
["CVE-2024-3094", "", True],
|
| 328 |
["CVE-2021-44228", "", True],
|
|
|
|
| 9 |
|
| 10 |
from __future__ import annotations
|
| 11 |
|
| 12 |
+
import spaces # ZeroGPU Space: required before other heavy imports
|
| 13 |
+
|
| 14 |
import json
|
| 15 |
import os
|
| 16 |
import re
|
|
|
|
| 280 |
return "\n".join(lines)
|
| 281 |
|
| 282 |
|
| 283 |
+
def _explain(cve_input: str, raw_description: str, use_llm: bool):
|
| 284 |
cve_input = (cve_input or "").strip()
|
| 285 |
raw_description = (raw_description or "").strip()
|
| 286 |
cve_id = parse_cve_id(cve_input) or parse_cve_id(raw_description)
|
|
|
|
| 325 |
return risk_md, header + report, json_out
|
| 326 |
|
| 327 |
|
| 328 |
+
@spaces.GPU(duration=90)
|
| 329 |
+
def explain(cve_input: str, raw_description: str, use_llm: bool):
|
| 330 |
+
"""Gradio entrypoint (ZeroGPU worker slot; work is mostly HTTP + optional Inference API)."""
|
| 331 |
+
return _explain(cve_input, raw_description, use_llm)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
EXAMPLES = [
|
| 335 |
["CVE-2024-3094", "", True],
|
| 336 |
["CVE-2021-44228", "", True],
|