// CONTENTS Part 08 · Knowledge and AI

// PART 08

Knowledge Base

Chapter 33 / 60 2 min read English Part 08 of 15

The Knowledge Base (KB) turns your documents into material the assistant can answer from. Documents live in a .gbkb/ folder inside the bot’s package, are indexed automatically, and are consulted when a question matches — no explicit search call is needed in a conversation.

Quick overview

Aspect How it works
Storage Documents in the S3-compatible drive, metadata in PostgreSQL, vectors in Qdrant
Search Dense vector search, optionally fused with keyword matching — chosen per bot by rag-mode
Formats PDF, DOCX, DOC, XLSX, XLS, ODS, PPTX, PPT, ODP, EPUB, ODT, TXT, MD, HTML, CSV, JSON, YAML, TOML and 30+ text-based formats
Integration Relevant content is injected into the model’s context automatically

Organising documents

Folders inside .gbkb/ become collections:

bot.gbkb/
├── policies/      → USE KB "policies"
├── products/      → USE KB "products"
└── support/       → USE KB "support"

Each folder is indexed separately and can be activated independently. In a script, USE KB "policies" scopes the conversation to that collection; the chat assistant activates collections based on the question.

Using it

' Load a knowledge base
USE KB "policies"

' The bot now answers questions using that knowledge

Documents are indexed when added and re-processed when they change — the drive monitor notices the file change, so updating a PDF updates the answers without a rebuild.

Saved documents as citations

Documents saved in the Docs app are indexed in a separate, structure-aware index. GET /api/docs/kb/search returns citation identity — document id, file, version, source reference, section and score — for documents the caller may read, never document text. In chat, a question about a saved document appends up to three citation-only lines to the system message for an authenticated user, under a SAVED DOCUMENT CITATIONS directive that tells the model to cite the exact file, version, section and page — and never to claim a document is missing from Drive.

Tenant isolation

Knowledge is scoped per bot and per tenant: a collection belongs to the bot whose package contains it, and queries resolve within the caller’s scope. One tenant’s documents never answer another tenant’s questions.

Practical advice

  • Organise folders by topic, not by file type — collections are activated by topic.
  • Keep filenames meaningful; they appear in answers and citations.
  • Prefer text-extractable documents: scanned images without a text layer have little to index.
  • For how retrieval decides what to inject — and the honest limits — read the next two chapters.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move