import httpx, os
from fastapi import APIRouter, Depends
from core.auth import verify_token

router = APIRouter()
OLLAMA = os.environ.get("OLLAMA_URL", "http://localhost:11434")

@router.get("/models")
async def models(_=Depends(verify_token)):
    async with httpx.AsyncClient() as c:
        try:
            r = await c.get(f"{OLLAMA}/api/tags", timeout=5)
            return r.json()
        except Exception:
            return {"models": []}
