windlass.providers.vectordb.chroma¶
chroma
¶
ChromaDB vector store.
Chroma is the pragmatic middle ground: persistent on disk with no server to run, or client/server when you need it, with native metadata filtering. Windlass uses Chroma purely as storage — embeddings are always computed by the configured Windlass embedder, so switching stores never silently switches embedding models.
Install with::
pip install "windlass[chroma]"
Example
from windlass import Windlass # doctest: +SKIP store = Windlass.vectordb("chroma", persist_path="./chroma") # doctest: +SKIP
ChromaVectorStore
¶
ChromaVectorStore(
*,
collection: str = "windlass",
dimensions: int | None = None,
metric: str = "cosine",
persist_path: str | None = None,
host: str | None = None,
port: int = 8000,
client: Any = None,
**config: Any
)
Bases: VectorStore
Vector store backed by ChromaDB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
str
|
Chroma collection name. |
'windlass'
|
dimensions
|
int | None
|
Vector length. Chroma infers it, so this is informational. |
None
|
metric
|
str
|
|
'cosine'
|
persist_path
|
str | None
|
Directory for the embedded persistent client. When omitted an ephemeral in-memory client is used. |
None
|
host
|
str | None
|
Server host for client/server mode. Takes precedence over
|
None
|
port
|
int
|
Server port. |
8000
|
client
|
Any
|
Pass a pre-configured |
None
|
**config
|
Any
|
Forwarded to :class: |
{}
|
Raises:
| Type | Description |
|---|---|
MissingDependencyError
|
When |
ProviderError
|
When the client or collection cannot be created. |
Note
Chroma stores metadata values as scalars only. Windlass JSON-encodes lists and dicts on write and decodes them on read, so nested metadata round-trips correctly.
Source code in src\windlass\providers\vectordb\chroma.py
native
¶
aadd
async
¶
Upsert chunks into the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
Sequence[Chunk]
|
Chunks with embeddings set. |
required |
Returns:
| Type | Description |
|---|---|
int
|
How many chunks were written. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If a chunk has no embedding. |
ProviderError
|
When Chroma rejects the batch. |
Source code in src\windlass\providers\vectordb\chroma.py
adelete
async
¶
Delete by id or metadata filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
Sequence[str] | None
|
Chunk ids to remove. |
None
|
filters
|
MetadataFilter | None
|
Metadata constraints, translated to Chroma's |
None
|
Returns:
| Type | Description |
|---|---|
int
|
How many chunks were removed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When neither argument is supplied. |
Source code in src\windlass\providers\vectordb\chroma.py
aclear
async
¶
Delete and recreate the collection.
Source code in src\windlass\providers\vectordb\chroma.py
asearch
async
¶
asearch(
vector: Sequence[float],
k: int = 5,
*,
filters: MetadataFilter | None = None,
**kwargs: Any
) -> list[ScoredChunk]
Query the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
Sequence[float]
|
The query embedding. |
required |
k
|
int
|
How many results to return. |
5
|
filters
|
MetadataFilter | None
|
Metadata constraints, pushed down to Chroma. |
None
|
**kwargs
|
Any
|
Extra keyword arguments for |
{}
|
Returns:
| Type | Description |
|---|---|
list[ScoredChunk]
|
Ranked hits. Chroma returns distances; they are converted to |
list[ScoredChunk]
|
similarity so higher is always better. |
Source code in src\windlass\providers\vectordb\chroma.py
aget
async
¶
Fetch chunks by id.
Source code in src\windlass\providers\vectordb\chroma.py
acount
async
¶
all_chunks
¶
Return every stored chunk, for building a companion lexical index.
Note
Loads the whole collection into memory. Fine for the tens of thousands of chunks a hybrid retriever needs; not something to call on a multi-million-row collection.