scripts/debug_qdrant_state.py hinzugefügt
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 1s
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 1s
This commit is contained in:
parent
b46e5461a7
commit
314fc8ac94
63
scripts/debug_qdrant_state.py
Normal file
63
scripts/debug_qdrant_state.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
scripts/debug_qdrant_state.py
|
||||
Zeigt Prefix, Collections und einfache Counts (notes/chunks/edges) + sample note_ids.
|
||||
|
||||
Aufruf:
|
||||
export COLLECTION_PREFIX="mindnet"
|
||||
python3 -m scripts.debug_qdrant_state
|
||||
# oder:
|
||||
python3 -m scripts.debug_qdrant_state --prefix mindnet
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, os, json
|
||||
from app.core.qdrant import QdrantConfig, get_client
|
||||
|
||||
def count_points(client, collection: str) -> int:
|
||||
try:
|
||||
res = client.count(collection, exact=True)
|
||||
return int(getattr(res, "count", 0))
|
||||
except Exception:
|
||||
pts, _ = client.scroll(collection, limit=1)
|
||||
return 1 if pts else 0
|
||||
|
||||
def sample_ids(client, collection: str, id_key: str, limit: int = 5):
|
||||
pts, _ = client.scroll(collection, with_payload=True, with_vectors=False, limit=limit)
|
||||
out = []
|
||||
for p in pts or []:
|
||||
pl = p.payload or {}
|
||||
if id_key in pl:
|
||||
out.append(pl[id_key])
|
||||
return out
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--prefix", default=os.environ.get("COLLECTION_PREFIX", "mindnet"))
|
||||
args = ap.parse_args()
|
||||
|
||||
cfg = QdrantConfig.from_env()
|
||||
cfg.prefix = args.prefix
|
||||
client = get_client(cfg)
|
||||
|
||||
notes = f"{cfg.prefix}_notes"
|
||||
chunks = f"{cfg.prefix}_chunks"
|
||||
edges = f"{cfg.prefix}_edges"
|
||||
|
||||
print(json.dumps({
|
||||
"prefix": cfg.prefix,
|
||||
"collections": {"notes": notes, "chunks": chunks, "edges": edges},
|
||||
"counts": {
|
||||
"notes": count_points(client, notes),
|
||||
"chunks": count_points(client, chunks),
|
||||
"edges": count_points(client, edges),
|
||||
},
|
||||
"samples": {
|
||||
"notes.note_id": sample_ids(client, notes, "note_id"),
|
||||
"chunks.note_id": sample_ids(client, chunks, "note_id"),
|
||||
"edges.note_id": sample_ids(client, edges, "note_id"),
|
||||
}
|
||||
}, ensure_ascii=False, indent=2))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user