Spaces:
Sleeping
Sleeping
Download backend/app/api/models.py from neongeckocom/LLM_Comparison_Tool: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/neongeckocom/LLM_Comparison_Tool/resolve/main/backend/app/api/models.py
- Command line
-
hf download hf://spaces/neongeckocom/LLM_Comparison_Tool/backend/app/api/models.py
-
curl -L -o models.py https://huggingface.co/spaces/neongeckocom/LLM_Comparison_Tool/resolve/main/backend/app/api/models.py
1.44 kB
| from __future__ import annotations | |
| import logging | |
| from fastapi import APIRouter | |
| from fastapi.responses import JSONResponse | |
| from app.clients.hana_client import hana_client | |
| from app.config import settings | |
| from app.services.model_status import check_all_model_statuses | |
| LOG = logging.getLogger(__name__) | |
| router = APIRouter() | |
| async def get_models(): | |
| """Return available Neon models (fresh from HANA) and comparison providers.""" | |
| try: | |
| neon_models = await hana_client.get_models() | |
| except Exception as exc: | |
| LOG.warning("HANA unavailable — Neon models will be empty: %s", exc) | |
| neon_models = [] | |
| comparison_providers = [] | |
| for p in settings.comparison_providers: | |
| comparison_providers.append({ | |
| "id": p["id"], | |
| "name": p["name"], | |
| "models": p["models"], | |
| }) | |
| return JSONResponse( | |
| content={ | |
| "neon_models": neon_models, | |
| "comparison_providers": comparison_providers, | |
| }, | |
| headers={"Cache-Control": "no-store"}, | |
| ) | |
| async def get_models_status(): | |
| """Probe each model with a tiny chat request and return online/unavailable/error.""" | |
| statuses = await check_all_model_statuses() | |
| return JSONResponse( | |
| content={"statuses": statuses}, | |
| headers={"Cache-Control": "no-store"}, | |
| ) | |