from fastapi import FastAPI, HTTPException from pydantic import BaseModel from nlp_service import analyse_emergency app = FastAPI() class EmergencyRequest(BaseModel): patient_id: str message: str class EmergencyResponse(BaseModel): patient_id: str urgency: str confidence: float action: str message: str @app.post("/api/emergency/analyse", response_model=EmergencyResponse) async def analyse(request: EmergencyRequest): if not request.message.strip(): raise HTTPException(status_code=400, detail="Message cannot be empty") result = analyse_emergency(request.message) return EmergencyResponse( patient_id=request.patient_id, urgency=result["urgency"], confidence=result["confidence"], action=result["action"], message=result["message"] ) @app.get("/") async def health_check(): return {"status": "BUTH NLP Service is running"}