ai-agent / testing.py
abdibrahem's picture
Update main.py and docker files
b9333d0
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)