File size: 1,012 Bytes
08b0543
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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

LOG = logging.getLogger(__name__)
router = APIRouter()


@router.get("/models")
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"},
    )