Spaces:
Runtime error
Runtime error
Commit
Β·
081c109
1
Parent(s):
c1a2741
Upd env startup
Browse files- src/api/routes/user.py +3 -1
- src/data/mongodb.py +1 -1
- 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 |
-
|
|
|
|
|
|
|
| 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("
|
| 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:
|
| 41 |
-
print("π API documentation at:
|
| 42 |
-
print("π Health check at:
|
| 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 |
|