scripts/setup_mindnet_collections.py aktualisiert
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 2s

This commit is contained in:
Lars 2025-09-01 17:21:10 +02:00
parent 3325f8571e
commit e19a5e1f5b

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Richtet die Qdrant-Collections für das mindnet-Projekt ein (V1).
Richtet die Qdrant-Collections für das mindnet-Projekt ein (V2).
- mindnet_chunks : semantische Suche über Text-Chunks (384/Cosine)
- mindnet_notes : 1 Punkt pro Notiz (optional Titel-Embedding)
@ -55,10 +55,18 @@ def main():
ap.add_argument("--distance", default="Cosine", choices=["Cosine", "Euclid", "Dot"], help="Distanzmetrik")
args = ap.parse_args()
# Qdrant-URL überschreiben, falls per Argument gesetzt
global DEFAULT_QDRANT_URL
DEFAULT_QDRANT_URL = args.qdrant_url
# Hier brauchen wir KEIN global, wir überschreiben einfach die Variable lokal
qdrant_url = args.qdrant_url
# Hilfsfunktion neu binden
def rq(method: str, path: str, **kwargs) -> requests.Response:
url = qdrant_url.rstrip("/") + path
r = requests.request(method, url, timeout=15, **kwargs)
if not r.ok:
raise RuntimeError(f"{method} {url} -> {r.status_code} {r.text}")
return r
# Ab hier wie gehabt
chunks = f"{args.prefix}_chunks"
notes = f"{args.prefix}_notes"
edges = f"{args.prefix}_edges"
@ -68,7 +76,7 @@ def main():
create_collection(notes, size=args.dim, distance=args.distance)
create_collection(edges, size=1, distance=args.distance) # Dummy-Vektor
# 2) Indizes
# 2) Indizes setzen
for f in ["note_id", "Status", "Typ", "title", "path"]:
create_keyword_index(chunks, f)
for f in ["tags", "Rolle", "links"]:
@ -83,14 +91,7 @@ def main():
for f in ["src_note_id", "dst_note_id", "src_chunk_id", "dst_chunk_id", "link_text", "relation"]:
create_keyword_index(edges, f)
# 3) Ausgabe
# 3) Übersicht ausgeben
r = rq("GET", "/collections")
print("\n[Info] Collections vorhanden:")
print(json.dumps(r.json().get("result", {}).get("collections", []), indent=2, ensure_ascii=False))
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"[ERROR] {e}", file=sys.stderr)
sys.exit(1)