symfonic.knowledge.adapters.chroma¶
chroma ¶
ChromaKnowledgeProvider -- RAG adapter for local ChromaDB collections.
Requires the knowledge optional dependency group::
pip install symfonic-core[knowledge]
All sync ChromaDB calls are wrapped with asyncio.to_thread for non-blocking operation in async contexts.
ChromaKnowledgeProvider ¶
KnowledgeProvider backed by a local ChromaDB persistent collection.
Connects to an existing ChromaDB directory and queries a named collection using ChromaDB's built-in default embedding function. For custom embeddings, pre-embed queries externally and use a different adapter.
All synchronous ChromaDB operations are wrapped with asyncio.to_thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Filesystem path to the ChromaDB persistent directory. |
required |
collection_name
|
str
|
Name of the collection to query. |
required |
Example::
provider = ChromaKnowledgeProvider(
path="/data/chroma",
collection_name="legal_docs",
)
fragments = await provider.search("force majeure clause", limit=5)
Source code in src/symfonic/knowledge/adapters/chroma.py
collection_info
async
¶
Return collection metadata.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
Source code in src/symfonic/knowledge/adapters/chroma.py
search
async
¶
Query the collection using ChromaDB's built-in embedding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Natural language search query. |
required |
limit
|
int
|
Maximum number of fragments to return. |
3
|
Returns:
| Type | Description |
|---|---|
list[KnowledgeFragment]
|
List of KnowledgeFragment sorted by descending score. |