Chroma Class — langchain Architecture
Architecture documentation for the Chroma class in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab["Chroma"] 9d2a2799_754f_4de7_e4e6_081d8ea620e0["VectorStore"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|extends| 9d2a2799_754f_4de7_e4e6_081d8ea620e0 d4a05de9_1f0f_3b21_8171_181bb47227ef["vectorstores.py"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|defined in| d4a05de9_1f0f_3b21_8171_181bb47227ef 5850e811_c55d_a2f8_15f1_17047150a50a["__init__()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 5850e811_c55d_a2f8_15f1_17047150a50a 5b1a46f4_cf99_423b_b281_e9ded4030f18["__ensure_collection()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 5b1a46f4_cf99_423b_b281_e9ded4030f18 13e731c1_dd84_1521_13d7_e6e72dedc9f8["_collection()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 13e731c1_dd84_1521_13d7_e6e72dedc9f8 2c07cafb_bafd_b1ba_ea9d_b567233e8c5a["embeddings()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 2c07cafb_bafd_b1ba_ea9d_b567233e8c5a 180f6c1b_bb48_bf57_69cd_8e866f8993df["__query_collection()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 180f6c1b_bb48_bf57_69cd_8e866f8993df 1fa15e9e_3ad0_16db_c7ff_a4a326370de0["encode_image()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 1fa15e9e_3ad0_16db_c7ff_a4a326370de0 7d6b252e_48b9_704e_b6e9_207055bfbff1["fork()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 7d6b252e_48b9_704e_b6e9_207055bfbff1 37a23069_1b1e_eff0_d830_afb8dfa98dd5["add_images()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 37a23069_1b1e_eff0_d830_afb8dfa98dd5 c6cde3f6_740c_9c74_569c_bdc91a7bd836["add_texts()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| c6cde3f6_740c_9c74_569c_bdc91a7bd836 1807ab11_64ca_e35a_9cf9_7abe78780268["hybrid_search()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 1807ab11_64ca_e35a_9cf9_7abe78780268 c2e030db_b7f7_376a_9ad2_1a06dee8dcd8["similarity_search()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| c2e030db_b7f7_376a_9ad2_1a06dee8dcd8 76615968_7cd6_d5f7_a619_c032edfc26cb["similarity_search_by_vector()"] d25f9e94_3ec0_b9ca_7d2f_eb7ef487ccab -->|method| 76615968_7cd6_d5f7_a619_c032edfc26cb
Relationship Graph
Source Code
libs/partners/chroma/langchain_chroma/vectorstores.py lines 155–1459
class Chroma(VectorStore):
"""Chroma vector store integration.
Setup:
Install `chromadb`, `langchain-chroma` packages:
```bash
pip install -qU chromadb langchain-chroma
```
Key init args — indexing params:
collection_name:
Name of the collection.
embedding_function:
Embedding function to use.
Key init args — client params:
client:
Chroma client to use.
client_settings:
Chroma client settings.
persist_directory:
Directory to persist the collection.
host:
Hostname of a deployed Chroma server.
port:
Connection port for a deployed Chroma server. Default is 8000.
ssl:
Whether to establish an SSL connection with a deployed Chroma server. Default is False.
headers:
HTTP headers to send to a deployed Chroma server.
chroma_cloud_api_key:
Chroma Cloud API key.
tenant:
Tenant ID. Required for Chroma Cloud connections. Default is 'default_tenant' for local Chroma servers.
database:
Database name. Required for Chroma Cloud connections. Default is 'default_database'.
Instantiate:
```python
from langchain_chroma import Chroma
from langchain_openai import OpenAIEmbeddings
vector_store = Chroma(
collection_name="foo",
embedding_function=OpenAIEmbeddings(),
# other params...
)
```
Add Documents:
```python
from langchain_core.documents import Document
document_1 = Document(page_content="foo", metadata={"baz": "bar"})
document_2 = Document(page_content="thud", metadata={"bar": "baz"})
document_3 = Document(page_content="i will be deleted :(")
documents = [document_1, document_2, document_3]
ids = ["1", "2", "3"]
vector_store.add_documents(documents=documents, ids=ids)
```
Update Documents:
```python
updated_document = Document(
page_content="qux",
metadata={"bar": "baz"},
)
vector_store.update_documents(ids=["1"], documents=[updated_document])
```
Delete Documents:
```python
vector_store.delete(ids=["3"])
```
Search:
```python
results = vector_store.similarity_search(query="thud", k=1)
Extends
Source
Frequently Asked Questions
What is the Chroma class?
Chroma is a class in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is Chroma defined?
Chroma is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 155.
What does Chroma extend?
Chroma extends VectorStore.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free