whung99 Claude Opus 4.6 commited on
Commit
87c2f5d
·
1 Parent(s): 4432e84

fix: don't crash on missing GOOGLE_API_KEY at startup

Browse files

Warn instead of raising RuntimeError so HF Space can boot
and show the UI. The key is set via HF Space secrets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. backend/main.py +3 -2
backend/main.py CHANGED
@@ -21,10 +21,11 @@ from urgency import load_model
21
 
22
  load_dotenv()
23
 
24
- # Fail fast if Gemini API key is missing
25
  api_key = os.getenv("GOOGLE_API_KEY")
26
  if not api_key or api_key == "your_key_here":
27
- raise RuntimeError("GOOGLE_API_KEY not set. Check backend/.env")
 
28
 
29
  FRONTEND_URL = os.getenv("FRONTEND_URL", "http://localhost:5173")
30
 
 
21
 
22
  load_dotenv()
23
 
24
+ # Warn if Gemini API key is missing (don't crash — HF Spaces sets secrets as env vars)
25
  api_key = os.getenv("GOOGLE_API_KEY")
26
  if not api_key or api_key == "your_key_here":
27
+ import warnings
28
+ warnings.warn("GOOGLE_API_KEY not set. Add it as a Secret in HuggingFace Space settings.")
29
 
30
  FRONTEND_URL = os.getenv("FRONTEND_URL", "http://localhost:5173")
31