Skip to content

symfonic.knowledge.protocols

protocols

Protocol interfaces for the knowledge retrieval layer.

KnowledgeProvider is the single abstract interface that all RAG adapters must satisfy. Implementations can connect to ChromaDB, Pinecone, Qdrant, or any other vector store.

Architecture note: the protocol is @runtime_checkable so that adapters can be validated with isinstance() without requiring explicit inheritance.

KnowledgeProvider

Bases: Protocol

Abstract interface for semantic knowledge retrieval (RAG).

Concrete implementations connect to vector databases (ChromaDB, Pinecone, Qdrant, etc.) and return scored knowledge fragments.

All methods are async. Synchronous backends must wrap blocking calls with asyncio.to_thread.

collection_info async

collection_info() -> dict[str, Any]

Return metadata about the connected collection.

Returns:

Type Description
dict[str, Any]

Dict with at least name and count keys.

Source code in src/symfonic/knowledge/protocols.py
async def collection_info(self) -> dict[str, Any]:
    """Return metadata about the connected collection.

    Returns:
        Dict with at least ``name`` and ``count`` keys.
    """
    ...

search async

search(
    query: str, limit: int = 3
) -> list[KnowledgeFragment]

Search for knowledge fragments matching the query.

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.

Source code in src/symfonic/knowledge/protocols.py
async def search(
    self,
    query: str,
    limit: int = 3,
) -> list[KnowledgeFragment]:
    """Search for knowledge fragments matching the query.

    Args:
        query: Natural language search query.
        limit: Maximum number of fragments to return.

    Returns:
        List of KnowledgeFragment sorted by descending score.
    """
    ...