17 lines
441 B
Python
17 lines
441 B
Python
from pathlib import Path
|
|
|
|
import chromadb
|
|
|
|
from app.core.config import get_settings
|
|
|
|
|
|
def get_chroma_client() -> chromadb.Client:
|
|
settings = get_settings()
|
|
persist_dir = Path(settings.chroma_db_path)
|
|
persist_dir.mkdir(parents=True, exist_ok=True)
|
|
return chromadb.PersistentClient(path=str(persist_dir))
|
|
|
|
|
|
def get_or_create_collection(client: chromadb.Client, name: str):
|
|
return client.get_or_create_collection(name=name)
|