Spaces:
Running
Running
Update streamlit_app.py
Browse files- streamlit_app.py +7 -5
streamlit_app.py
CHANGED
|
@@ -35,11 +35,13 @@ def get_client(space_id: str, hf_token: Optional[str]) -> Client:
|
|
| 35 |
"""
|
| 36 |
if not hf_token:
|
| 37 |
return Client(space_id)
|
| 38 |
-
# Gradio client renamed the token kwarg; try
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
@dataclass
|
|
|
|
| 35 |
"""
|
| 36 |
if not hf_token:
|
| 37 |
return Client(space_id)
|
| 38 |
+
# Gradio client renamed the token kwarg; try a few fallbacks for compatibility
|
| 39 |
+
for kwargs in ({"hf_token": hf_token}, {"token": hf_token}, {"headers": {"Authorization": f"Bearer {hf_token}"}}):
|
| 40 |
+
try:
|
| 41 |
+
return Client(space_id, **kwargs)
|
| 42 |
+
except TypeError:
|
| 43 |
+
continue
|
| 44 |
+
return Client(space_id)
|
| 45 |
|
| 46 |
|
| 47 |
@dataclass
|