FSA-PROJECT-CV / app /configs /qdrant_db.py
HuyDN
Phase2/HuyDN: Optimization speed and fix bugs
d6ef950
raw
history blame
No virus
973 Bytes
from qdrant_client import QdrantClient
from qdrant_client.http import models
import os
from dotenv import load_dotenv
load_dotenv()
qdrant_client = QdrantClient(
url = os.getenv("QDRANT_URL"),
api_key = os.getenv("QDRANT_API_KEY"),
)
print("Qdrant Database connected")
# 2. Check if the question_tests exists
if qdrant_client.collection_exists('question_tests') == False:
qdrant_client.create_collection(
collection_name="question_tests",
vectors_config=models.VectorParams(size=768, distance=models.Distance.COSINE),
)
print("Collection question_tests created")
# 3. Check if the rag_documents_test exists
elif qdrant_client.collection_exists('rag_documents_test') == False:
qdrant_client.create_collection(
collection_name="rag_documents_test",
vectors_config=models.VectorParams(size=768, distance=models.Distance.COSINE),
)
print("Collection rag_documents_test created")
else:
print("Collections already exist")