amarorn commited on
Commit
d65751c
·
verified ·
1 Parent(s): 178ff41

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -18,19 +18,21 @@ SYSTEM_PROMPT = (
18
 
19
  F = TypeVar("F", bound=Callable[..., Any])
20
 
21
- # ZeroGPU Spaces require at least one @spaces.GPU function at startup.
22
- # We only do remote HTTP inference — decorate anyway so ZeroGPU hardware boots.
23
- try:
24
- import spaces # type: ignore
25
- except ImportError: # local / CPU Space
26
- spaces = None
27
-
28
 
29
  def gpu_if_zerogpu(fn: F) -> F:
30
- if spaces is None:
 
 
 
 
 
 
 
 
 
 
 
31
  return fn
32
- # Short duration: function only waits on Inference API, no local CUDA kernels
33
- return spaces.GPU(duration=120)(fn) # type: ignore[return-value]
34
 
35
 
36
  def _settings() -> dict[str, str]:
 
18
 
19
  F = TypeVar("F", bound=Callable[..., Any])
20
 
 
 
 
 
 
 
 
21
 
22
  def gpu_if_zerogpu(fn: F) -> F:
23
+ """
24
+ ZeroGPU Spaces require at least one @spaces.GPU at startup.
25
+ We only call remote Inference API — decorate when the real HF `spaces` lib is present.
26
+ """
27
+ try:
28
+ import spaces # type: ignore
29
+
30
+ gpu = getattr(spaces, "GPU", None)
31
+ if gpu is None:
32
+ return fn
33
+ return gpu(duration=120)(fn) # type: ignore[return-value]
34
+ except Exception: # noqa: BLE001 — local / CPU / wrong PyPI package
35
  return fn
 
 
36
 
37
 
38
  def _settings() -> dict[str, str]: