LiamKhoaLe commited on
Commit
081c109
Β·
1 Parent(s): c1a2741

Upd env startup

Browse files
Files changed (3) hide show
  1. src/api/routes/user.py +3 -1
  2. src/data/mongodb.py +1 -1
  3. start.py +19 -3
src/api/routes/user.py CHANGED
@@ -145,7 +145,9 @@ async def update_patient(patient_id: str, req: PatientUpdateRequest):
145
  async def search_patients_route(q: str, limit: int = 10):
146
  try:
147
  logger.info(f"GET /patients/search q='{q}' limit={limit}")
148
- return {"results": search_patients(q, limit=limit)}
 
 
149
  except Exception as e:
150
  logger.error(f"Error searching patients: {e}")
151
  raise HTTPException(status_code=500, detail=str(e))
 
145
  async def search_patients_route(q: str, limit: int = 10):
146
  try:
147
  logger.info(f"GET /patients/search q='{q}' limit={limit}")
148
+ results = search_patients(q, limit=limit)
149
+ logger.info(f"Search returned {len(results)} results")
150
+ return {"results": results}
151
  except Exception as e:
152
  logger.error(f"Error searching patients: {e}")
153
  raise HTTPException(status_code=500, detail=str(e))
src/data/mongodb.py CHANGED
@@ -41,7 +41,7 @@ def get_database() -> Database:
41
  logger.error(f"Failed to connect to MongoDB: {str(e)}")
42
  # Pass the error down, code that calls this function should handle it
43
  raise e
44
- db_name = os.getenv("MONGO_DB", "medicaldiagnosissystem")
45
  return _mongo_client[db_name]
46
 
47
  def close_connection():
 
41
  logger.error(f"Failed to connect to MongoDB: {str(e)}")
42
  # Pass the error down, code that calls this function should handle it
43
  raise e
44
+ db_name = os.getenv("USER_DB", "medicaldiagnosissystem")
45
  return _mongo_client[db_name]
46
 
47
  def close_connection():
start.py CHANGED
@@ -36,10 +36,26 @@ def main():
36
  else:
37
  print(f"βœ… Found {len(gemini_keys)} Gemini API keys")
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  print("\nπŸ“± Starting Medical AI Assistant...")
40
- print("🌐 Web UI will be available at: http://localhost:7860")
41
- print("πŸ“š API documentation at: http://localhost:7860/docs")
42
- print("πŸ” Health check at: http://localhost:7860/health")
43
  print("\nPress Ctrl+C to stop the server")
44
  print("=" * 50)
45
 
 
36
  else:
37
  print(f"βœ… Found {len(gemini_keys)} Gemini API keys")
38
 
39
+ # Check for MongoDB environment variables
40
+ mongo_user = os.getenv("MONGO_USER")
41
+ user_db = os.getenv("USER_DB")
42
+
43
+ if not mongo_user:
44
+ print("❌ Error: MONGO_USER environment variable not found!")
45
+ print("Set MONGO_USER environment variable for database connectivity.")
46
+ sys.exit(1)
47
+
48
+ if not user_db:
49
+ print("❌ Error: USER_DB environment variable not found!")
50
+ print("Set USER_DB environment variable for database connectivity.")
51
+ sys.exit(1)
52
+
53
+ print("βœ… MongoDB environment variables found")
54
+
55
  print("\nπŸ“± Starting Medical AI Assistant...")
56
+ print("🌐 Web UI will be available at: https://medai-cos30018-medicaldiagnosissystem.hf.space")
57
+ print("πŸ“š API documentation at: https://medai-cos30018-medicaldiagnosissystem.hf.space/docs")
58
+ print("πŸ” Health check at: https://medai-cos30018-medicaldiagnosissystem.hf.space/health")
59
  print("\nPress Ctrl+C to stop the server")
60
  print("=" * 50)
61