Spaces:
Sleeping
Sleeping
Add @spaces.GPU decorator to fix HF Spaces runtime error
Browse filesHuggingFace Spaces requires at least one @spaces.GPU decorated function
when GPU hardware is detected (from sentence-transformers).
Added a dummy GPU warmup function to satisfy this requirement.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app_unified.py +15 -0
app_unified.py
CHANGED
|
@@ -6,6 +6,13 @@ import logging
|
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import Tuple
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Simple mode imports
|
| 10 |
from openai import OpenAI
|
| 11 |
from src.config import get_config
|
|
@@ -22,6 +29,14 @@ logging.basicConfig(level=logging.INFO)
|
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
class UnifiedAssistant:
|
| 26 |
"""Unified assistant supporting both simple and multi-agent modes."""
|
| 27 |
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import Tuple
|
| 8 |
|
| 9 |
+
# Import spaces for HuggingFace GPU decorator
|
| 10 |
+
try:
|
| 11 |
+
import spaces
|
| 12 |
+
HF_SPACES = True
|
| 13 |
+
except ImportError:
|
| 14 |
+
HF_SPACES = False
|
| 15 |
+
|
| 16 |
# Simple mode imports
|
| 17 |
from openai import OpenAI
|
| 18 |
from src.config import get_config
|
|
|
|
| 29 |
logger = logging.getLogger(__name__)
|
| 30 |
|
| 31 |
|
| 32 |
+
# Dummy GPU function to satisfy HuggingFace Spaces GPU check
|
| 33 |
+
if HF_SPACES:
|
| 34 |
+
@spaces.GPU
|
| 35 |
+
def _hf_spaces_gpu_warmup():
|
| 36 |
+
"""Dummy function to satisfy HF Spaces GPU decorator requirement."""
|
| 37 |
+
return "GPU ready"
|
| 38 |
+
|
| 39 |
+
|
| 40 |
class UnifiedAssistant:
|
| 41 |
"""Unified assistant supporting both simple and multi-agent modes."""
|
| 42 |
|