25 lines
821 B
Python
25 lines
821 B
Python
import httpx
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import JSONResponse
|
|
from app.core.env_setting import EnvSetting
|
|
|
|
settings = EnvSetting()
|
|
router = APIRouter()
|
|
|
|
@router.get("/ai/health")
|
|
async def ai():
|
|
try:
|
|
async with httpx.AsyncClient() as client:
|
|
response = await client.get(
|
|
f"{settings.AI_SERVER_URL}",
|
|
headers={
|
|
"Cookie": settings.AI_SERVER_COOKIE_VALUE
|
|
},
|
|
timeout=5.0
|
|
)
|
|
if response.status_code == 200:
|
|
return response.json()
|
|
else:
|
|
return JSONResponse(content={"status": "unhealthy"}, status_code=500)
|
|
except Exception as e:
|
|
return JSONResponse(content={"status": "unhealthy", "error": str(e)}, status_code=500) |