Nymbo commited on
Commit
3fbb4bd
·
verified ·
1 Parent(s): 57c8ad1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1298,7 +1298,11 @@ def Generate_Image( # <-- MCP tool #5 (Generate Image)
1298
  if "503" in msg:
1299
  raise gr.Error("The model is warming up. Please try again shortly.")
1300
  if "401" in msg or "403" in msg:
1301
- raise gr.Error("Authentication failed. Set HF_READ_TOKEN environment variable with access to the model.")
 
 
 
 
1302
  _log_call_end("Generate_Image", f"error={_truncate_for_log(msg, 200)}")
1303
  raise gr.Error(f"Image generation failed: {msg}")
1304
 
@@ -1499,7 +1503,11 @@ def Generate_Video( # <-- MCP tool #6 (Generate Video)
1499
  if "503" in msg:
1500
  raise gr.Error("The model is warming up. Please try again shortly.")
1501
  if "401" in msg or "403" in msg:
1502
- raise gr.Error("Authentication failed or not permitted. Set HF_READ_TOKEN/HF_TOKEN with inference access.")
 
 
 
 
1503
  _log_call_end("Generate_Video", f"error={_truncate_for_log(msg, 200)}")
1504
  raise gr.Error(f"Video generation failed: {msg}")
1505
 
 
1298
  if "503" in msg:
1299
  raise gr.Error("The model is warming up. Please try again shortly.")
1300
  if "401" in msg or "403" in msg:
1301
+ raise gr.Error("Please duplicate the space and provide a `HF_READ_TOKEN` to enable Image and Video Generation.")
1302
+ # Map common provider auth messages to the same friendly guidance
1303
+ low = msg.lower()
1304
+ if ("api_key" in low) or ("hf auth login" in low) or ("unauthorized" in low) or ("forbidden" in low):
1305
+ raise gr.Error("Please duplicate the space and provide a `HF_READ_TOKEN` to enable Image and Video Generation.")
1306
  _log_call_end("Generate_Image", f"error={_truncate_for_log(msg, 200)}")
1307
  raise gr.Error(f"Image generation failed: {msg}")
1308
 
 
1503
  if "503" in msg:
1504
  raise gr.Error("The model is warming up. Please try again shortly.")
1505
  if "401" in msg or "403" in msg:
1506
+ raise gr.Error("Please duplicate the space and provide a `HF_READ_TOKEN` to enable Image and Video Generation.")
1507
+ # Map common provider auth messages to the same friendly guidance
1508
+ low = msg.lower()
1509
+ if ("api_key" in low) or ("hf auth login" in low) or ("unauthorized" in low) or ("forbidden" in low):
1510
+ raise gr.Error("Please duplicate the space and provide a `HF_READ_TOKEN` to enable Image and Video Generation.")
1511
  _log_call_end("Generate_Video", f"error={_truncate_for_log(msg, 200)}")
1512
  raise gr.Error(f"Video generation failed: {msg}")
1513