From ac5fbe1fdd9a30e1a9f07e2918745ae6682319ce Mon Sep 17 00:00:00 2001 From: Brett England Date: Thu, 21 Mar 2024 20:32:36 -0400 Subject: [PATCH] wipe qdrant support --- scripts/utils.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/utils.py b/scripts/utils.py index 48068789..9db4d005 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -11,6 +11,7 @@ def wipe() -> None: "simple": wipe_simple, # node store "chroma": wipe_chroma, # vector store "postgres": wipe_postgres, # node, index and vector store + "qdrant": wipe_qdrant, # vector store } for dbtype in ("nodestore", "vectorstore"): database = getattr(settings(), dbtype).database @@ -93,11 +94,28 @@ def wipe_postgres(dbtype: str) -> None: conn.close() -def wipe_chroma(dbtype: str): +def wipe_chroma(dbtype: str) -> None: assert dbtype == "vectorstore" wipe_tree(str((local_data_path / "chroma_db").absolute())) +def wipe_qdrant(dbtype: str) -> None: + assert dbtype == "vectorstore" + try: + from qdrant_client import QdrantClient # type: ignore + except ImportError: + raise ImportError("Qdrant dependencies not found") + client = QdrantClient( + **settings().qdrant.model_dump(exclude_none=True) + ) + collection_name = "make_this_parameterizable_per_api_call" # ?! see vector_store_component.py + try: + client.delete_collection(collection_name) + print("Collection dropped successfully.") + except Exception as e: + print("Error dropping collection:", e) + + if __name__ == "__main__": commands = { "wipe": wipe,