fix(rag): Auto-create Qdrant collection on first index
All checks were successful
CI / go-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 33s
CI / test-python-voice (push) Successful in 36s
CI / deploy-hetzner (push) Successful in 38s
CI / python-lint (push) Has been skipped
CI / test-bqas (push) Successful in 31s

Collections may not exist if init_collections() failed at startup
(e.g. Qdrant not ready). Now index_documents() ensures the
collection exists before upserting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-11 21:02:05 +01:00
parent 7c932c441f
commit be45adb975

View File

@@ -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]