app/routers/admin.py hinzugefügt
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
ba17516814
commit
0f2f8208e3
60
app/routers/admin.py
Normal file
60
app/routers/admin.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"""
|
||||
app/routers/admin.py — Admin-/Monitoring-Endpunkte (optional)
|
||||
|
||||
Zweck:
|
||||
Liefert einfache Kennzahlen zu Collections (Counts) und Config.
|
||||
Kompatibilität:
|
||||
Python 3.12+, FastAPI 0.110+, qdrant-client 1.x
|
||||
Version:
|
||||
0.1.0 (Erstanlage)
|
||||
Stand:
|
||||
2025-10-07
|
||||
Bezug:
|
||||
- Qdrant Collections: *_notes, *_chunks, *_edges
|
||||
Nutzung:
|
||||
app.include_router(admin.router, prefix="/admin", tags=["admin"])
|
||||
Änderungsverlauf:
|
||||
0.1.0 (2025-10-07) – Erstanlage.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
from qdrant_client import QdrantClient
|
||||
from app.config import get_settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/stats")
|
||||
def stats():
|
||||
s = get_settings()
|
||||
client = QdrantClient(url=s.QDRANT_URL, api_key=s.QDRANT_API_KEY)
|
||||
notes = f"{s.COLLECTION_PREFIX}_notes"
|
||||
chunks = f"{s.COLLECTION_PREFIX}_chunks"
|
||||
edges = f"{s.COLLECTION_PREFIX}_edges"
|
||||
|
||||
def _count(col: str) -> int:
|
||||
try:
|
||||
return client.count(collection_name=col, exact=True).count
|
||||
except Exception:
|
||||
return -1
|
||||
|
||||
return {
|
||||
"collections": {
|
||||
"notes": {"name": notes, "count": _count(notes)},
|
||||
"chunks": {"name": chunks, "count": _count(chunks)},
|
||||
"edges": {"name": edges, "count": _count(edges)},
|
||||
},
|
||||
"config": {
|
||||
"qdrant": s.QDRANT_URL,
|
||||
"prefix": s.COLLECTION_PREFIX,
|
||||
"vector_size": s.VECTOR_SIZE,
|
||||
"distance": s.DISTANCE,
|
||||
"retriever": {
|
||||
"w_sem": s.RETRIEVER_W_SEM,
|
||||
"w_edge": s.RETRIEVER_W_EDGE,
|
||||
"w_cent": s.RETRIEVER_W_CENT,
|
||||
"top_k": s.RETRIEVER_TOP_K,
|
||||
"expand_depth": s.RETRIEVER_EXPAND_DEPTH,
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user