Knowledge bases

A knowledge base is a corpus your agent can retrieve from. You add sources to it, attach it to an agent, and the agent pulls the most relevant passages into the conversation.

Adding sources

A source is a file or a URL. Create the knowledge base first, then add sources to it, either at creation time or afterwards. Each source records its own type and filename so you can tell where an answer came from.

add-source.sh
curl -X POST https://api.saaya.ai/api/v1/knowledge-bases/{kb_id}/sources \
  -H "X-API-Key: sa_..." \
  -H "Content-Type: application/json" \
  -d '{
    "type": "pdf",
    "filename": "company-handbook.pdf",
    "file_url": "https://storage.example.com/docs/company-handbook.pdf"
  }'

Keeping sources fresh

Turn on auto-refresh and the knowledge base re-reads its sources on its own. You can also trigger a sync on demand when you know something changed and do not want to wait.

Tuning retrieval

Retrieval is tuned where the knowledge base is attached to the agent, not on the knowledge base itself. Two dials matter: a minimum relevance score, below which a passage is not handed to the model at all, and a top-k limit on how many passages come back. Raise the score to cut noise; raise top-k when answers are missing context.

Was this page helpful?