Sourav Sharma Claude Opus 5 commited on
Commit ·
f7f62d8
1
Parent(s): e96413a
Fix the backend connection under gradio_client 2.x
Browse filesMoving to the Gradio SDK pulled in gradio_client 2.6.0, which renamed the
Client token argument from hf_token to token. The old keyword raised
TypeError inside get_client(), which generate() caught and reported as
"Backend unavailable", so every generation failed with the backend healthy
and HF_TOKEN correctly set.
Passes the token positionally: it is the second parameter in both 1.x and
2.x, so this works whichever version sdk_version installs. Verified the
connection succeeds against the inference Space on 1.13.3 and 2.6.0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -54,7 +54,10 @@ def get_client() -> Client:
|
|
| 54 |
"HF_TOKEN is not set on this Space. The inference backend is "
|
| 55 |
"private and cannot be reached without it."
|
| 56 |
)
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
return _client
|
| 59 |
|
| 60 |
|
|
|
|
| 54 |
"HF_TOKEN is not set on this Space. The inference backend is "
|
| 55 |
"private and cannot be reached without it."
|
| 56 |
)
|
| 57 |
+
# Passed positionally on purpose: this argument is named hf_token in
|
| 58 |
+
# gradio_client 1.x and token in 2.x, and the Space installs whichever
|
| 59 |
+
# version sdk_version pulls in. It is the second parameter in both.
|
| 60 |
+
_client = Client(BACKEND, token)
|
| 61 |
return _client
|
| 62 |
|
| 63 |
|