GPU 서버 중앙 AI 라우팅 서비스 초기 구현: - OpenAI 호환 API (/v1/chat/completions, /v1/models, /v1/embeddings) - 모델 레지스트리 + 백엔드 헬스체크 (30초 루프) - Ollama SSE 프록시 (NDJSON → OpenAI SSE 변환) - JWT 인증 이중 경로 (httpOnly 쿠키 + Bearer 토큰) - owner/guest 역할 분리, 로그인 rate limiting - 백엔드별 rate limiting (NanoClaude 대비) - SQLite 스키마 사전 정의 (aiosqlite + WAL) - Docker Compose + Caddy 리버스 프록시 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
795 B
Python
32 lines
795 B
Python
from fastapi import APIRouter
|
|
|
|
from services.gpu_monitor import get_gpu_info
|
|
from services.registry import registry
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
|
|
@router.get("/health")
|
|
async def health():
|
|
gpu = await get_gpu_info()
|
|
return {
|
|
"status": "ok",
|
|
"backends": registry.get_health_summary(),
|
|
"gpu": gpu,
|
|
}
|
|
|
|
|
|
@router.get("/health/{backend_id}")
|
|
async def backend_health(backend_id: str):
|
|
backend = registry.backends.get(backend_id)
|
|
if not backend:
|
|
return {"error": {"message": f"Backend '{backend_id}' not found"}}
|
|
|
|
return {
|
|
"id": backend.id,
|
|
"type": backend.type,
|
|
"status": "healthy" if backend.healthy else "down",
|
|
"models": [m.id for m in backend.models],
|
|
"latency_ms": backend.latency_ms,
|
|
}
|