File size: 582 Bytes
b4c7867
 
ca39256
7921d06
 
1bfb390
 
 
 
 
 
8593064
ca39256
7921d06
1bfb390
 
 
 
 
 
8593064
7921d06
1bfb390
 
b4c7867
1bfb390
 
 
 
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
import os
import chromadb
from src.storage.paths import nb_root


def chroma_client(username, notebook_id):

    persist_dir = os.path.join(
        nb_root(username, notebook_id),
        "chroma"
    )

    os.makedirs(persist_dir, exist_ok=True)

    return chromadb.PersistentClient(
        path=persist_dir,
        settings=chromadb.config.Settings(
            anonymized_telemetry=False
        )
    )


def get_collection(username, notebook_id):

    client = chroma_client(username, notebook_id)

    return client.get_or_create_collection(
        name="notebook"
    )