Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -905,12 +905,42 @@ def create_ui():
|
|
| 905 |
# ---------------------------
|
| 906 |
# Launch application
|
| 907 |
# ---------------------------
|
| 908 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 909 |
demo = create_ui()
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 905 |
# ---------------------------
|
| 906 |
# Launch application
|
| 907 |
# ---------------------------
|
| 908 |
+
try:
|
| 909 |
+
print("🚀 Starting MCQ Test Generator Pro v2.0")
|
| 910 |
+
print(f"📦 Gradio version: {gr.__version__}")
|
| 911 |
+
|
| 912 |
+
# Check API key
|
| 913 |
+
if not GROQ_API_KEY:
|
| 914 |
+
print("⚠️ WARNING: GROQ_API_KEY not found in environment variables")
|
| 915 |
+
print("Please set it in Hugging Face Space Settings > Repository secrets")
|
| 916 |
+
else:
|
| 917 |
+
print(f"✅ API Key configured (length: {len(GROQ_API_KEY)})")
|
| 918 |
+
|
| 919 |
+
# Create and launch
|
| 920 |
demo = create_ui()
|
| 921 |
+
print("✅ UI created successfully")
|
| 922 |
+
|
| 923 |
+
demo.queue() # Enable queue for better handling
|
| 924 |
+
demo.launch()
|
| 925 |
+
|
| 926 |
+
except Exception as e:
|
| 927 |
+
print(f"❌ Critical Error: {str(e)}")
|
| 928 |
+
import traceback
|
| 929 |
+
traceback.print_exc()
|
| 930 |
+
|
| 931 |
+
# Create minimal error interface
|
| 932 |
+
with gr.Blocks() as error_demo:
|
| 933 |
+
gr.Markdown(f"""
|
| 934 |
+
# ❌ Application Error
|
| 935 |
+
|
| 936 |
+
**Error Message:** {str(e)}
|
| 937 |
+
|
| 938 |
+
**Common Solutions:**
|
| 939 |
+
1. Check if GROQ_API_KEY is set in Space settings
|
| 940 |
+
2. Verify all dependencies are installed
|
| 941 |
+
3. Check the build logs for errors
|
| 942 |
+
|
| 943 |
+
**Contact:** Developer - Najaf Ali Sharqi
|
| 944 |
+
""")
|
| 945 |
+
|
| 946 |
+
error_demo.launch()
|