vibesecurityguy commited on
Commit
dba649b
Β·
verified Β·
1 Parent(s): f3c13ec

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -5,6 +5,29 @@ Dual-mode inference:
5
  - Fallback: OpenAI API (user provides their own key)
6
  """
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  import json
9
  import logging
10
  import os
 
5
  - Fallback: OpenAI API (user provides their own key)
6
  """
7
 
8
+ # ── HfFolder compatibility shim ──────────────────────────────────────────
9
+ # Gradio's oauth.py imports HfFolder from huggingface_hub, but HfFolder was
10
+ # removed in huggingface_hub >= 0.24. This shim must run BEFORE importing
11
+ # Gradio so the import chain doesn't break.
12
+ try:
13
+ from huggingface_hub import HfFolder # noqa: F401
14
+ except ImportError:
15
+ import huggingface_hub
16
+
17
+ class _HfFolder:
18
+ """Minimal shim for the removed HfFolder class."""
19
+
20
+ @classmethod
21
+ def get_token(cls):
22
+ return huggingface_hub.get_token()
23
+
24
+ @classmethod
25
+ def save_token(cls, token):
26
+ huggingface_hub.login(token=token)
27
+
28
+ huggingface_hub.HfFolder = _HfFolder
29
+ # ──────────────────────────────────────────────────────────────────────────
30
+
31
  import json
32
  import logging
33
  import os