danswer/backend/model_server/management_endpoints.py
Yuhong Sun 6026536110
Model Server Async (#3386)
* need-verify

* fix some lib calls

* k

* tests

* k

* k

* k

* Address the comments

* fix comment
2024-12-11 01:33:44 +00:00

21 lines
537 B
Python

import torch
from fastapi import APIRouter
from fastapi import Response
router = APIRouter(prefix="/api")
@router.get("/health")
async def healthcheck() -> Response:
return Response(status_code=200)
@router.get("/gpu-status")
async def gpu_status() -> dict[str, bool | str]:
if torch.cuda.is_available():
return {"gpu_available": True, "type": "cuda"}
elif torch.backends.mps.is_available():
return {"gpu_available": True, "type": "mps"}
else:
return {"gpu_available": False, "type": "none"}