Skip to content

Adapters

from rag_audit.adapters import ChromaDBAdapter, VectorStoreAdapter

All adapters implement the VectorStoreAdapter protocol:

adapter.add(ids, texts, embeddings)   # index documents
adapter.query(embedding, k)           # retrieve top-k texts
adapter.delete(ids)                   # remove documents
adapter.count()                       # collection size

ChromaDBAdapter

Wraps a ChromaDB collection. Accepts an existing client for testing or a path for persistent storage.

# Ephemeral (default — in-memory)
adapter = ChromaDBAdapter("my-collection")

# Persistent
adapter = ChromaDBAdapter("my-collection", path="./chroma_db")

# Inject client (e.g. for tests)
import chromadb
adapter = ChromaDBAdapter("my-collection", client=chromadb.EphemeralClient())

Methods

add

adapter.add(ids=["id1", "id2"], texts=["doc one", "doc two"], embeddings=[[...], [...]])

query

Returns the texts of the k nearest neighbors. If k exceeds the collection size, returns all available documents.

results: list[str] = adapter.query(embedding=[...], k=5)

delete

adapter.delete(ids=["id1"])

count

n: int = adapter.count()

Stubs

PineconeAdapter and QdrantAdapter are available but raise NotImplementedError — full implementations are planned for a future release.