Files
abot/qdrant_functions.py
2026-01-14 01:41:03 -08:00

30 lines
900 B
Python

# qdrant_functions.py
import logging
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
import uuid
import os
QDRANT_HOST = os.getenv("QDRANT_HOST", "localhost")
QDRANT_PORT = int(os.getenv("QDRANT_PORT", 6333))
QDRANT_COLLECTION = os.getenv("QDRANT_COLLECTION", "abot-slack")
client = QdrantClient(host=QDRANT_HOST, port=QDRANT_PORT)
embedding_model = SentenceTransformer("all-MiniLM-L6-v2")
VECTOR_SIZE = 384
def ensure_collection():
collections = [c.name for c in client.get_collections().collections]
if QDRANT_COLLECTION not in collections:
client.create_collection(
collection_name=QDRANT_COLLECTION,
vectors_config={
"size": VECTOR_SIZE,
"distance": "Cosine"
}
)
logging.info(f"Created Qdrant collection {QDRANT_COLLECTION}")
ensure_collection()