Skip to main content
A language model answers from what it learned in training. A knowledge base lets an agent answer from your documents instead — scheme rules, policy PDFs, product manuals — by retrieving relevant passages at call time and giving them to the model. This is retrieval-augmented generation: retrieve the relevant text, then generate an answer grounded in it.

The ingest pipeline

Upload a document and the API extracts its text, splits it into overlapping chunks, embeds each chunk, and stores the vectors in Chroma. The document’s metadata and status live in FerretDB; the vectors live on the voicera_oss_chroma_data volume. Every organisation shares one rag_docs collection (rag/chroma_store.py); isolation comes from the per-org directory each store is opened in, not from the collection name. Defaults, from apps/api/app/rag/ingest_pipeline.py: Ingestion is asynchronous. A document moves through processingready, or failed.

Per-organisation collections

Chunks are scoped to the organisation that uploaded them. A retrieval never crosses that boundary, so two tenants sharing a deployment cannot read each other’s documents.

The two retrieval modes

Set mode on the agent’s knowledge_base block. They behave very differently.
Retrieve on every turn, prepend to the message.Before the model sees the caller’s message, the runtime retrieves the top matching chunks and augments the message with them.
  • Predictable — grounding is always present.
  • Costs one retrieval per turn, and spends tokens even when the turn needed no lookup.
  • Good for narrow agents where nearly every question is about the documents.
This is the default.
Implemented in apps/runtime/services/knowledge/: context_processor.py is a Pipecat frame processor for context mode, tool.py builds the tool definition for tool mode, and setup.py wires whichever the agent selected.

Attaching documents to an agent

top_k is the accuracy-versus-cost dial: more chunks give the model more to work with and cost more tokens per turn.
The runtime parses this block more permissively than the API validates it — an unknown mode falls back to context, and top_k is clamped. A document written straight into FerretDB can therefore behave differently from one created through the API.

Retrieval at call time

Retrieval goes through the API rather than the runtime reaching into Chroma directly:
The route is internal — it takes the service key, not a user token.

Managing documents

See Managing knowledge documents.

Requirements and limits

The dashboard’s Knowledge Base screen is backed by the API — it lists, previews, uploads, and deletes documents through /knowledge. The API remains the complete surface; the screen covers the common operations. See Dashboard tour.

Tuning retrieval quality