diff --git a/app.py b/app.py index 2b6a142..c245b3e 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,7 @@ from fastapi import FastAPI, HTTPException from fastapi.responses import FileResponse, JSONResponse from fastapi.staticfiles import StaticFiles -from routers import jobs, maintenance, models, system, cookbook +from routers import jobs, maintenance, models, system, cookbook, integration app = FastAPI(title="Mission Control") @@ -41,6 +41,7 @@ app.include_router(jobs.router) app.include_router(maintenance.router) app.include_router(system.router) app.include_router(cookbook.router) +app.include_router(integration.router) _STATIC = Path(__file__).parent / "static" diff --git a/routers/integration.py b/routers/integration.py new file mode 100644 index 0000000..18d3517 --- /dev/null +++ b/routers/integration.py @@ -0,0 +1,24 @@ +""" +Integrations-Router: testet die OpenAI-kompatible Verbindung zur LLM-Engine. +Damit der „Verbinden"-Assistent dem Nutzer sagen kann: funktioniert ✓ + welche Modelle. +""" + +from fastapi import APIRouter, Depends + +from auth import auth +from config import LLAMA_SWAP_URL +from llamaswap import _swap_get + +router = APIRouter(prefix="/api/integration", dependencies=[Depends(auth)]) + + +@router.get("/test") +def test_connection(): + """Ruft die OpenAI-kompatible Modell-Liste der Engine ab (das, was externe Tools nutzen).""" + try: + data = _swap_get("/v1/models") + items = data.get("data", data) if isinstance(data, dict) else data + models = [m.get("id") for m in (items or []) if isinstance(m, dict) and m.get("id")] + return {"ok": True, "models": models, "url": LLAMA_SWAP_URL} + except Exception as exc: # noqa: BLE001 + return {"ok": False, "error": str(exc), "url": LLAMA_SWAP_URL} diff --git a/static/index.html b/static/index.html index c5b2a2c..ace5eeb 100644 --- a/static/index.html +++ b/static/index.html @@ -19,6 +19,7 @@ Aktivität Server Cookbook + Verbinden Guides
${esc(snippet)}