Update app.py
Browse files
app.py
CHANGED
|
@@ -283,9 +283,25 @@ def run_workflow(
|
|
| 283 |
"✅ Chart generation complete!",
|
| 284 |
)
|
| 285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
except Exception as e:
|
| 287 |
import traceback
|
| 288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
return (None, None, None, None, None, error_msg)
|
| 290 |
|
| 291 |
|
|
@@ -418,5 +434,6 @@ if __name__ == "__main__":
|
|
| 418 |
demo.launch(
|
| 419 |
server_name="0.0.0.0",
|
| 420 |
server_port=7860,
|
| 421 |
-
share=
|
| 422 |
-
)
|
|
|
|
|
|
| 283 |
"✅ Chart generation complete!",
|
| 284 |
)
|
| 285 |
|
| 286 |
+
except ValueError as e:
|
| 287 |
+
# API key or configuration errors
|
| 288 |
+
error_msg = f"❌ Configuration Error: {str(e)}\n\nPlease check your API keys in HuggingFace Spaces settings."
|
| 289 |
+
return (None, None, None, None, None, error_msg)
|
| 290 |
except Exception as e:
|
| 291 |
import traceback
|
| 292 |
+
error_type = type(e).__name__
|
| 293 |
+
error_msg = f"❌ Error ({error_type}): {str(e)}\n\n"
|
| 294 |
+
|
| 295 |
+
# Provide helpful messages for common errors
|
| 296 |
+
if "API" in error_type or "Connection" in error_type or "Illegal header" in str(e):
|
| 297 |
+
error_msg += "💡 Tip: Check your API key in HuggingFace Spaces settings. Make sure there are no extra spaces or newlines."
|
| 298 |
+
elif "model" in str(e).lower():
|
| 299 |
+
error_msg += "💡 Tip: The selected model might not be available. Try a different model."
|
| 300 |
+
|
| 301 |
+
# Only show full traceback in development (not in production)
|
| 302 |
+
if os.getenv("DEBUG", "false").lower() == "true":
|
| 303 |
+
error_msg += f"\n\nFull traceback:\n{traceback.format_exc()}"
|
| 304 |
+
|
| 305 |
return (None, None, None, None, None, error_msg)
|
| 306 |
|
| 307 |
|
|
|
|
| 434 |
demo.launch(
|
| 435 |
server_name="0.0.0.0",
|
| 436 |
server_port=7860,
|
| 437 |
+
share=False,
|
| 438 |
+
)
|
| 439 |
+
|