# Knowledge

> Documents and chunks for retrieval with an embedding and a tsvector each, scoped to an organization, agent, project, chat, user or record (subject) and grouped into collections with a visibility, a priority and grants, plus system documents shared with every tenant; hybrid search with reciprocal rank fusion, chunks that keep their embedding when unchanged, and an embed job per document when jobs is installed. With ai-files and jobs, queue_knowledge_file ingests a file through a job.

- Category: AI
- Module: `knowledge`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/knowledge
- Page: https://bettersupabase.com/blocks/knowledge

## Install

```bash
npx better-supabase add knowledge
```

The command also installs `updated-at`, `memberships`, `vector-search`, `permissions`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by knowledge; add installs them too.
    "updated-at": {},
    memberships: {},
    "vector-search": {},
    permissions: {},
    // Modes: "managed". The default is "managed".
    knowledge: { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/knowledge`.

## Related blocks

Requires: [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md), [vector-search](https://bettersupabase.com/blocks/vector-search.md)

Works with: [ai-chat](https://bettersupabase.com/blocks/ai-chat.md), [ai-files](https://bettersupabase.com/blocks/ai-files.md), [queue](https://bettersupabase.com/blocks/queue.md), [subjects](https://bettersupabase.com/blocks/subjects.md), [teams](https://bettersupabase.com/blocks/teams.md)

## Recipes

- [Knowledge base upload](https://bettersupabase.com/recipes/knowledge-upload.md): A form that adds a document to the knowledge base, which chunks and embeds it for search.
