Spaces:
Sleeping
Sleeping
Commit ·
c7362f7
1
Parent(s): 189dd71
Dynamically inspect Client constructor signature for token argument
Browse files
app.py
CHANGED
|
@@ -43,9 +43,18 @@ def generate_exercise_video(exercise_name):
|
|
| 43 |
)
|
| 44 |
|
| 45 |
try:
|
| 46 |
-
# Pass HF_TOKEN if available in the environment
|
|
|
|
| 47 |
hf_token = os.environ.get("HF_TOKEN")
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
result = client.predict(
|
| 51 |
prompt=prompt,
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
try:
|
| 46 |
+
# Pass HF_TOKEN if available in the environment, checking parameter name dynamically
|
| 47 |
+
import inspect
|
| 48 |
hf_token = os.environ.get("HF_TOKEN")
|
| 49 |
+
client_kwargs = {}
|
| 50 |
+
if hf_token:
|
| 51 |
+
sig = inspect.signature(Client.__init__)
|
| 52 |
+
if "token" in sig.parameters:
|
| 53 |
+
client_kwargs["token"] = hf_token
|
| 54 |
+
elif "hf_token" in sig.parameters:
|
| 55 |
+
client_kwargs["hf_token"] = hf_token
|
| 56 |
+
|
| 57 |
+
client = Client(T2V_SPACE, **client_kwargs)
|
| 58 |
|
| 59 |
result = client.predict(
|
| 60 |
prompt=prompt,
|