from fastapi import APIRouter from services.ollama_client import ollama_client from db.vector_store import vector_store router = APIRouter(tags=["health"]) @router.get("/health") async def health_check(): backends = await ollama_client.check_health() stats = vector_store.stats() # 메인 텍스트 모델명 결정 (Ollama 메인, MLX fallback) model_name = None ollama_models = backends.get("ollama", {}).get("models", []) if ollama_models: model_name = ollama_models[0] if not model_name and backends.get("mlx", {}).get("status") == "connected": model_name = backends["mlx"].get("model") return { "status": "ok", "service": "tk-ai-service", "model": model_name, "ollama": backends.get("ollama", {}), "mlx": backends.get("mlx", {}), "embeddings": stats, } @router.get("/models") async def list_models(): return await ollama_client.check_health()