- Ollama 메인 → MLX fallback 순서로 변경 (기존 MLX 우선 제거) - OLLAMA_BASE_URL을 gpu.hyungi.net으로 변경 (Docker 네트워크 호환) - OLLAMA_TEXT_MODEL을 qwen3:8b → qwen3.5:9b-q8_0으로 업데이트 - health 엔드포인트: model 필드 직접 반환, 이중 중첩 해소 - health 체크 타임아웃 120초 → 5초로 단축 - Ollama API 호출에 think: false 추가 (thinking 토큰 방지) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
959 B
Python
34 lines
959 B
Python
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()
|