From cecde4145a20cc1f31ae5840419ca6532f71b855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=B5=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A1=D0=B0?= =?UTF-8?q?=D1=82=D1=82=D0=B0=D1=80=D0=BE=D0=B2=D0=B0?= Date: Thu, 28 May 2026 13:25:58 +0000 Subject: [PATCH] Update rag_tools --- rag_tools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rag_tools.py b/rag_tools.py index a4d456e..0a35ea4 100644 --- a/rag_tools.py +++ b/rag_tools.py @@ -3,6 +3,7 @@ from qdrant_client import QdrantClient from langchain.embeddings.ollama import OllamaEmbeddings from langchain.vectorstores.qdrant import QdrantVectorStore from langchain.text_splitter import RecursiveCharacterTextSplitter +from langchain.schema import Document # Initialize embeddings and vector store embeddings = OllamaEmbeddings(model="nomic-embed-text") @@ -10,7 +11,9 @@ client = QdrantClient(host="localhost", port=6333) collection_name = "knowledge_base" # Ensure collection exists if not client.has_collection(collection_name): - client.create_collection(name=collection_name, vectors_config={"size": embeddings.embed_query(["test"]).shape[1], "distance": "Cosine"}) + # Determine embedding dimension by embedding a dummy text + dim = embeddings.embed_query(["test"])[0].shape[0] + client.create_collection(name=collection_name, vectors_config={"size": dim, "distance": "Cosine"}) vector_store = QdrantVectorStore(client=client, collection_name=collection_name, embedding=embeddings) # Text splitter