File size: 586 Bytes
a4c2dfd
 
 
 
 
37156ae
a4c2dfd
 
 
 
 
37156ae
a4c2dfd
 
 
 
 
 
 
 
 
 
 
 
 
37156ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
from qdrant_client import QdrantClient
from qdrant_client.http.models import VectorParams, Distance

COLLECTION = "esg_vectors"
VECTOR_SIZE = 512

os.makedirs("qdrant_db", exist_ok=True)

client = QdrantClient(path="qdrant_db")

def init():

    collections = [c.name for c in client.get_collections().collections]

    if COLLECTION not in collections:

        client.create_collection(
            collection_name=COLLECTION,
            vectors_config=VectorParams(
                size=VECTOR_SIZE,
                distance=Distance.COSINE
            )
        )

init()