app/main.py aktualisiert
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
This commit is contained in:
parent
0a891cfd95
commit
93ceff7f17
79
app/main.py
79
app/main.py
|
|
@ -1,6 +1,29 @@
|
||||||
"""
|
"""
|
||||||
Version 0.3
|
app/main.py — mindnet API bootstrap (WP-04 Hooks)
|
||||||
|
|
||||||
|
Zweck:
|
||||||
|
Startpunkt der FastAPI-Anwendung: Router-Registrierung und Healthcheck.
|
||||||
|
Ergänzt um optionale WP-04 Router (Graph/Retriever), falls vorhanden.
|
||||||
|
Kompatibilität:
|
||||||
|
Python 3.12+; FastAPI 0.110+ (getestet lokal)
|
||||||
|
Version:
|
||||||
|
0.4.0 (WP-04 Hooks: optionale Router, /admin/meta)
|
||||||
|
Stand:
|
||||||
|
2025-10-06
|
||||||
|
Bezug:
|
||||||
|
Handbuch & Knowledge Design (WP-03/04)
|
||||||
|
Umgebung:
|
||||||
|
Siehe app/config.py (QDRANT_URL, MINDNET_PREFIX, usw.)
|
||||||
|
Nutzung:
|
||||||
|
uvicorn app.main:app --reload --port 8000
|
||||||
|
Änderungsverlauf:
|
||||||
|
0.4.0 (2025-10-06) – /admin/meta ergänzt; optionale Einbindung von graph/query/admin Routern.
|
||||||
|
0.3.x (vorher) – Basisversion laut bereitgestellter Datei.
|
||||||
|
|
||||||
|
Hinweise:
|
||||||
|
Bestehende Routen/Funktionen bleiben unverändert.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
@ -8,6 +31,24 @@ from .config import get_settings
|
||||||
from .routers.embed_router import router as embed_router
|
from .routers.embed_router import router as embed_router
|
||||||
from .routers.qdrant_router import router as qdrant_router
|
from .routers.qdrant_router import router as qdrant_router
|
||||||
|
|
||||||
|
# Optionale WP-04 Router dynamisch einbinden, ohne harte Abhängigkeit:
|
||||||
|
def _maybe_include_wp04(app: FastAPI) -> None:
|
||||||
|
try:
|
||||||
|
from .routers.graph import router as graph_router # type: ignore
|
||||||
|
app.include_router(graph_router, prefix="/graph", tags=["graph"])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
from .routers.query import router as query_router # type: ignore
|
||||||
|
app.include_router(query_router, prefix="/query", tags=["query"])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
from .routers.admin import router as admin_router # type: ignore
|
||||||
|
app.include_router(admin_router, prefix="/admin", tags=["admin"])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> FastAPI:
|
def create_app() -> FastAPI:
|
||||||
app = FastAPI(title="mindnet API", version="0.1.0")
|
app = FastAPI(title="mindnet API", version="0.1.0")
|
||||||
|
|
@ -17,8 +58,44 @@ def create_app() -> FastAPI:
|
||||||
def healthz():
|
def healthz():
|
||||||
return {"status": "ok", "qdrant": s.QDRANT_URL, "prefix": s.COLLECTION_PREFIX}
|
return {"status": "ok", "qdrant": s.QDRANT_URL, "prefix": s.COLLECTION_PREFIX}
|
||||||
|
|
||||||
|
# Admin-Metadaten (WP-04)
|
||||||
|
@app.get("/admin/meta")
|
||||||
|
def admin_meta():
|
||||||
|
# Import lokal, damit fehlende Module nicht beim Start stören
|
||||||
|
meta = {}
|
||||||
|
try:
|
||||||
|
import app.main as _m
|
||||||
|
meta["main"] = getattr(_m, "__doc__", "").splitlines()[0:1]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
import app.config as _c
|
||||||
|
meta["config"] = {
|
||||||
|
"QDRANT_URL": s.QDRANT_URL,
|
||||||
|
"COLLECTION_PREFIX": s.COLLECTION_PREFIX,
|
||||||
|
"VECTOR_SIZE": s.VECTOR_SIZE,
|
||||||
|
"DISTANCE": s.DISTANCE,
|
||||||
|
"MODEL_NAME": s.MODEL_NAME,
|
||||||
|
"RETRIEVER": {
|
||||||
|
"W_SEM": getattr(s, "RETRIEVER_W_SEM", 0.70),
|
||||||
|
"W_EDGE": getattr(s, "RETRIEVER_W_EDGE", 0.25),
|
||||||
|
"W_CENT": getattr(s, "RETRIEVER_W_CENT", 0.05),
|
||||||
|
"TOP_K": getattr(s, "RETRIEVER_TOP_K", 10),
|
||||||
|
"EXPAND_DEPTH": getattr(s, "RETRIEVER_EXPAND_DEPTH", 1),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
import app.core.qdrant_points as _qp
|
||||||
|
meta["qdrant_points"] = getattr(_qp, "__doc__", "").splitlines()[0:1]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return {"meta": meta}
|
||||||
|
|
||||||
app.include_router(embed_router)
|
app.include_router(embed_router)
|
||||||
app.include_router(qdrant_router)
|
app.include_router(qdrant_router)
|
||||||
|
_maybe_include_wp04(app)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user