All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 4s
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
scripts/diag_payload_indexes.py (v1.1)
|
|
|
|
Zeigt payload_schema (Indizes) je Collection.
|
|
WICHTIG: Einige Qdrant-Versionen liefern payload_schema nur, wenn
|
|
`with_payload_schema=true` gesetzt wird. Daher setzen wir das Flag explizit.
|
|
"""
|
|
from __future__ import annotations
|
|
import argparse, json
|
|
from qdrant_client.http import models as rest
|
|
from app.core.qdrant import QdrantConfig, get_client, collection_names
|
|
|
|
def compact_schema(ps: dict | None) -> dict:
|
|
if not isinstance(ps, dict):
|
|
return {}
|
|
out = {}
|
|
for k, v in ps.items():
|
|
if isinstance(v, dict) and "type" in v:
|
|
out[k] = v["type"]
|
|
else:
|
|
out[k] = v
|
|
return out
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--raw", action="store_true")
|
|
args = ap.parse_args()
|
|
|
|
cfg = QdrantConfig.from_env()
|
|
client = get_client(cfg)
|
|
notes, chunks, edges = collection_names(cfg.prefix)
|
|
|
|
cols = [notes, chunks, edges]
|
|
result = []
|
|
for name in cols:
|
|
info = client.get_collection(collection_name=name, with_payload_schema=True)
|
|
d = info.model_dump() if hasattr(info, "model_dump") else (info.dict() if hasattr(info, "dict") else info)
|
|
payload_schema = (d.get("result") or {}).get("payload_schema")
|
|
vectors = (d.get("result") or {}).get("vectors")
|
|
if isinstance(vectors, dict) and "config" in vectors:
|
|
vectors = vectors.get("config")
|
|
if args.raw:
|
|
result.append({"collection": name, "raw": d})
|
|
else:
|
|
result.append({
|
|
"name": name,
|
|
"vectors": vectors,
|
|
"payload_schema": compact_schema(payload_schema),
|
|
"segments_count": (d.get("result") or {}).get("segments_count"),
|
|
})
|
|
print(json.dumps({"prefix": cfg.prefix, "collections": result}, ensure_ascii=False, indent=2))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|