2a60def469
- routers/integration.py: GET /api/integration/test ruft Engine /v1/models -> ok + Modell-Liste. - connect.js: Verbindungstest-Button, Bild/Vision-Flow (erkennt Vision-Modell, sonst Cookbook-Hinweis, OpenAI-Vision-Snippet), Tool-Configs (OpenCode/Cline/Cursor/OpenWebUI) mit Copy. - Nav-Eintrag 'Verbinden' + View + main.js Registrierung. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
25 lines
927 B
Python
25 lines
927 B
Python
"""
|
|
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}
|