From d0b18dc23640015507f6ae222f24a1ce852e650d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B0=D1=82=20=D0=A4=D0=B0=D0=B7=D1=8B?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2?= Date: Thu, 14 May 2026 16:53:45 +0000 Subject: [PATCH] add vector_store --- vector_store.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 vector_store.py diff --git a/vector_store.py b/vector_store.py new file mode 100644 index 0000000..65a2652 --- /dev/null +++ b/vector_store.py @@ -0,0 +1,21 @@ +from langchain_qdrant import QdrantVectorStore +from langchain_ollama import OllamaEmbeddings +from langchain.schema import Document + +class QdrantStore: + def __init__(self, host="localhost", port=6333, collection_name="rag_collection"): + self.client = QdrantVectorStore( + url=f"http://{host}:{port}", + collection_name=collection_name, + embeddings=OllamaEmbeddings(model="nomic-embed-text") + ) + # ensure collection exists + if not self.client.collection_exists: + self.client.create_collection() + + def add_documents(self, docs): + # docs: list of Document + self.client.add_documents(docs) + + def search(self, query, limit=5): + return self.client.similarity_search(query, k=limit)