The ChromaHandshake class provides seamless integration between Chonkie’s chunking system and ChromaDB, a popular vector database. Embed and store your Chonkie chunks in ChromaDB without ever leaving the Chonkie SDK.

Installation

Before using the Chroma handshake, make sure to install the required dependencies:
pip install chonkie[chroma]

Basic Usage

Initialization

from chonkie import ChromaHandshake

# Initialize with default settings (in-memory ChromaDB)
handshake = ChromaHandshake()

# Or specify a persistent storage path
handshake = ChromaHandshake(path="./chroma_db")

# Or use an existing Chroma client
import chromadb
client = chromadb.Client()
handshake = ChromaHandshake(client=client, collection_name="my_collection")

Writing Chunks to ChromaDB

from chonkie import ChromaHandshake, SemanticChunker

handshake = ChromaHandshake() # Initializes a new Chroma client

chunker = SemanticChunker()
chunks = chunker("Chonkie is the best chonker ever!")

handshake.write(chunks)

Parameters

client
Optional[chromadb.Client]
default:"None"
Chroma client instance. If not provided, a new client will be created.
collection_name
Union[str, Literal['random']]
default:"random"
Name of the collection to use. If “random”, a random name will be generated.
embedding_model
Union[str, BaseEmbeddings]
default:"minishlab/potion-retrieval-32M"
Embedding model to use.
path
Optional[str]
default:"None"
If provided, creates a persistent Chroma client at the specified path.