File size: 650 Bytes
12d0de7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
import chromadb
from chromadb.config import Settings
from helpers.configs import get_settings

# Globals
chroma_client = None
chroma_collection = None



def init_chroma():
    global chroma_client, chroma_collection
    settings = get_settings()

    chroma_client = chromadb.PersistentClient(
        path=settings.CHROMA_DB_PATH
    )

    chroma_collection = chroma_client.get_or_create_collection(
        name=settings.COLLECTION_NAME,
        #        metadata={"hnsw:space": "cosine"}
        metadata={"hnsw:space": "cosine"}
    )

    return chroma_client, chroma_collection


def get_chroma():
    return chroma_client, chroma_collection