From 339ca65c8ae57133b31cd3f3cf8a017365632f29 Mon Sep 17 00:00:00 2001 From: NirantK Date: Tue, 11 Jul 2023 19:09:59 +0530 Subject: [PATCH] * feat(usage.py): add usage example for upserting documents in QdrantClient --- usage.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 usage.py diff --git a/usage.py b/usage.py new file mode 100644 index 0000000..2570bd3 --- /dev/null +++ b/usage.py @@ -0,0 +1,31 @@ +from qdrant_client import QdrantClient + +# Initialize the client +client = QdrantClient(":memory:") # or QdrantClient(path="path/to/db") + +# Prepare your documents, metadata, and IDs +docs = [ + "Qdrant has Langchain integrations", + "Qdrant also has Llama Index integrations", + # ...more documents... +] +metadatas = [ + {"source": "notion"}, + {"source": "google-docs"}, + # ...more metadata... +] +ids = [ + 1, + 2, + 3, + 50, + 63, +] # unique for each doc, if not mentioned, we'll insert this sequentially + +# Use the new upsert_docs method +client.upsert_docs( + collection_name="demo_collection", + docs={"documents": docs, "metadatas": metadatas, "ids": ids}, + batch_size=512, # Adjust as needed + wait=True, # Wait for the operation to complete +)