multiple-changes-made
This commit is contained in:
29
rag/qdrant_functions.py
Normal file
29
rag/qdrant_functions.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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()
|
||||
Reference in New Issue
Block a user