singhankur01 commited on
Commit
e616961
·
verified ·
1 Parent(s): c7cf44e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -35,11 +35,13 @@ ml_models = {}
35
  async def lifespan(app: FastAPI):
36
  # This code runs ONCE when the application starts up
37
  print("🚀 Initializing models and prompt template...")
38
-
39
- # Use a consistent key name that you set in Hugging Face Secrets
40
- GOOGLE_API_KEY = os.getenv("gemini_api_key")
41
- if not GOOGLE_API_KEY:
42
- raise RuntimeError("CRITICAL: Missing GOOGLE_API_KEY in environment secrets!")
 
 
43
 
44
  # Load models into the shared dictionary
45
  ml_models["embedder"] = HuggingFaceEmbeddings(model_name="BAAI/bge-base-en-v1.5")
 
35
  async def lifespan(app: FastAPI):
36
  # This code runs ONCE when the application starts up
37
  print("🚀 Initializing models and prompt template...")
38
+
39
+ try:
40
+ GOOGLE_API_KEY = os.getenv("gemini_api_key")
41
+ print("🔑 gemini_api_key:", "FOUND" if GOOGLE_API_KEY else "NOT FOUND")
42
+
43
+ if not GOOGLE_API_KEY:
44
+ raise RuntimeError("CRITICAL: Missing GOOGLE_API_KEY in environment secrets!")
45
 
46
  # Load models into the shared dictionary
47
  ml_models["embedder"] = HuggingFaceEmbeddings(model_name="BAAI/bge-base-en-v1.5")