Skip to content

Vector

ChromaDB implementation of vector search and CRUD capability.

This module provides a ChromaDB implementation of the VectorCapability protocol using langchain-chroma integration.

ChromaVectorCapability(collection_name, em_invoker, client, num_candidates=DEFAULT_NUM_CANDIDATES, encryption=None, default_batch_size=None)

Bases: BaseVectorCapability

ChromaDB implementation of VectorCapability protocol.

This class provides document CRUD operations and vector search using ChromaDB.

Attributes:

Name Type Description
collection_name str

The name of the ChromaDB collection.

collection Collection

The ChromaDB collection instance.

vector_store Chroma

The langchain Chroma vector store instance.

num_candidates int

The maximum number of candidates to consider during search.

Initialize the ChromaDB vector capability.

Parameters:

Name Type Description Default
collection_name str

The name of the ChromaDB collection.

required
em_invoker BaseEMInvoker

The embedding model to perform vectorization.

required
client ClientAPI

The ChromaDB client instance.

required
num_candidates int

Maximum number of candidates to consider during search. Defaults to 50.

DEFAULT_NUM_CANDIDATES
encryption EncryptionCapability | None

Encryption capability for field-level encryption. Defaults to None.

None
default_batch_size int | None

Default batch size for batching operations. Defaults to None.

None

ensure_index(**kwargs) async

Ensure ChromaDB collection exists, creating it if necessary.

This method is idempotent - if the collection already exists, it will return the existing collection. The collection is automatically created during initialization, but this method can be called explicitly to ensure it exists.

Parameters:

Name Type Description Default
**kwargs Any

Unused; for interface compatibility.

{}

Raises:

Type Description
RuntimeError

If collection creation fails.