symfonic.knowledge.adapters¶
adapters ¶
Concrete KnowledgeProvider adapters.
ChromaKnowledgeProvider requires the knowledge extra (chromadb).
It used to be imported here inside a try/except ImportError that
appended it to __all__ on success -- which meant every import of this
package probed for chromadb, and the package's export surface silently
depended on what happened to be installed.
Both problems have the same fix: resolve the adapter through a module
__getattr__ (PEP 562). The name is always exported, absence is reported
at first use with the install command, and importing the package reaches no
distribution at all (rule IA-5 of the integration-adapter standard, T4.2.1).
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 symfonic/knowledge/adapters/chroma.py
collection_info
async
¶
Return collection metadata.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with |
Source code in 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. |