Spaces:
Sleeping
Sleeping
File size: 1,294 Bytes
b9333d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import Dict, Any, Optional
from final import AIAgent
app = FastAPI(
title="Healthcare AI Assistant",
description="An AI-powered healthcare assistant that handles appointment booking and queries",
version="1.0.0"
)
# Initialize the AI agent
agent = AIAgent()
class QueryRequest(BaseModel):
query: str
language: Optional[str] = None
class QueryResponse(BaseModel):
routing_info: Dict[str, Any]
api_response: Dict[str, Any]
user_friendly_response: str
detected_language: str
sentiment: Dict[str, Any]
@app.post("/query", response_model=QueryResponse)
async def process_query(request: QueryRequest):
"""
Process a user query and return a response
"""
try:
response = agent.process_user_query(request.query)
return response
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/health")
async def health_check():
"""
Health check endpoint
"""
return {"status": "healthy", "service": "healthcare-ai-assistant"}
@app.get("/")
async def root():
return {"message": "Hello World"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000) |