diff --git a/rag-service/qdrant_client_wrapper.py b/rag-service/qdrant_client_wrapper.py index cfd1bbe..c4b27e4 100644 --- a/rag-service/qdrant_client_wrapper.py +++ b/rag-service/qdrant_client_wrapper.py @@ -105,6 +105,13 @@ class QdrantClientWrapper: # Indexing # ------------------------------------------------------------------ + async def ensure_collection(self, name: str, vector_size: int = 1024) -> None: + """Create collection if it doesn't exist.""" + try: + self.client.get_collection(name) + except Exception: + await self.create_collection(name, vector_size) + async def index_documents( self, collection: str, @@ -118,6 +125,10 @@ class QdrantClientWrapper: f"vectors ({len(vectors)}) and payloads ({len(payloads)}) must have equal length" ) + # Auto-create collection if missing + vector_size = len(vectors[0]) if vectors else 1024 + await self.ensure_collection(collection, vector_size) + if ids is None: ids = [str(uuid.uuid4()) for _ in vectors]