Files
DocsGPT/docs/content/Sources/Wiki-sources.mdx
T

119 lines
6.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Wiki Sources — Living, LLM-Editable Documentation
description: Create a knowledge source that the agent can read and write — a living wiki it keeps up to date, with human edits, provenance stamps, and version safety.
---
import { Callout } from 'nextra/components'
# Wiki Sources
A **wiki source** is a knowledge source that the agent can both read *and* write. Instead of being a fixed set of ingested files, a wiki is a small set of Markdown pages that the LLM edits over time — recording what it learns, correcting stale information, and building living documentation. Humans can edit the same pages directly, and every change is stamped with who made it.
Unlike a classic source, a wiki is **team-scoped, not per-user**: it is shared and edited at the source level, so a whole team works against the same living document.
## How a wiki differs from a classic source
| | Classic source | Wiki source |
| --- | --- | --- |
| Content | Ingested files, read-only | Markdown pages, read **and** write |
| Who edits | You (re-upload to change) | The agent and humans |
| Default exposure | `prefetch` (chunks injected up front) | `agentic_tool` (the agent browses pages on demand) |
| Searchability | Embedded at ingest | Re-embedded automatically on every edit |
| Scope | Per owner | Team-shareable, edited at source scope |
Because a wiki defaults to the `agentic_tool` [exposure](/Sources/Per-source-configuration#exposure-prefetch-vs-agentic-tool), the agent navigates it as a tool — opening, searching, and editing pages as needed — rather than receiving a bulk prefetch.
## How the agent edits a wiki
The agent edits a wiki through an internal **Wiki tool** that is automatically scoped to one wiki source. It supports a small, edit-safe action surface:
- **view** a page,
- **create** or overwrite a page,
- **str_replace** an exact, unique string,
- **insert** at a line,
- **delete** a page,
- **rename** a page.
Two safety properties matter:
- **Provenance stamps.** Every page records whether its last change came from a human or the agent, so edits are traceable.
- **Optimistic versioning.** Edits carry an expected version; if a page changed underneath, the edit is rejected rather than silently clobbering a concurrent change. String replacements must match exactly and uniquely.
After any edit, the affected page is **re-embedded asynchronously** so the wiki stays searchable and the new content is immediately retrievable.
<Callout type="info" emoji="ℹ️">
Each wiki page is capped at 1 MB (1,000,000 bytes). Pages are addressed by path (the home page is `/index.md`).
</Callout>
## Creating a wiki
In the UI, choose **New wiki source** when adding a source. From the API:
```bash
curl -X POST https://your-docsgpt/api/sources/wiki \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{ "name": "Team Handbook", "initial_content": "# Team Handbook\n\nWelcome." }'
```
- `name` (required) — the wiki source name.
- `initial_content` (optional) — Markdown that seeds the home page `/index.md` and triggers its first re-embed.
No ingestion task runs for a wiki; pages are authored directly. The response returns the new `source_id`.
## Converting an existing source into a wiki
You can turn an already-ingested source into a wiki so the agent can start maintaining it:
```bash
curl -X POST https://your-docsgpt/api/sources/<source_id>/wiki/convert \
-H "Authorization: Bearer <token>"
```
- A **blank** source is enabled inline (no task) and immediately becomes a wiki.
- A source **with files** runs a conversion task that reassembles its existing chunks into wiki pages; poll the returned task for a per-file summary.
- Conversion is rejected with `409` if the source is still ingesting — wait for it to finish first.
<Callout type="warning" emoji="⚠️">
Switching a source to (or from) wiki mode goes only through `POST /api/sources/<id>/wiki/convert`. It cannot be done through the [config PATCH endpoint](/Sources/Per-source-configuration#editing-the-config-via-api).
</Callout>
## Reading and editing pages directly
Humans can read and edit wiki pages through the API (and the wiki viewer in the UI):
```text
GET /api/sources/<source_id>/wiki/pages # list pages
GET /api/sources/<source_id>/wiki/page?path=... # fetch one page fresh
PUT /api/sources/<source_id>/wiki/page # create or overwrite a page (human edit)
```
Human edits are stamped with `human` provenance and trigger the same re-embed as agent edits. Read access follows source sharing (owner or anyone the source is shared with); writing requires owner or team `editor` access.
## Edits from the API, widget and public links
An agent called with its API key (the website widget, the API) runs as its owner, so it could change any wiki the owner can edit. By default it can't: API and widget users can still read the wiki through the agent, but the agent isn't offered the create, edit, delete or rename actions in those chats, and the Wiki tool refuses them if it's asked anyway.
The wiki's owner can allow such edits. On the **Sources** page, open the wiki's menu, choose **Wiki settings**, and turn on **Let API and widget users edit this wiki**. The change applies from the next message, including in chats that are already open. Only the owner sees it; team editors can't change it. You and the wiki's editors can always edit it in DocsGPT, and so can agents you or they use there.
The switch doesn't cover public links. People who open an agent from its public link run it as themselves, so they can only edit wikis they could edit anyway (their own, or ones shared with them as an editor). Because the agent's prompt and sources belong to someone else, each of their wiki edits waits for their approval in the chat before it runs. A research agent can't stop to ask, so in a public-link chat it reads the wiki but doesn't edit it.
Scheduled and webhook runs don't get the Wiki tool, so they read a wiki through search but never edit it.
<Callout type="warning" emoji="⚠️">
With authentication off (`AUTH_TYPE=None`, the default), every request, including one from the widget or the API, runs as the same `local` user who owns the agents. The switch then can't tell outside callers from you and has no effect, so turn authentication on if others can reach the widget or the API.
</Callout>
From the API, only a signed-in session can change the setting; a personal access token can read it but not change it:
```text
GET /api/sources/<source_id>/wiki/settings # {"allow_outside_edits": false, ...}
PUT /api/sources/<source_id>/wiki/settings # owner only; body {"allow_outside_edits": true}
```
## Related
- [Per-Source Configuration](/Sources/Per-source-configuration) — exposure and retrieval settings a wiki uses.
- [Access Control & Teams](/Deploying/Access-Control) — sharing a wiki with a team.
- [Connectors](/Guides/Connectors#agents-used-through-an-api-key) — what else an agent can and can't do for API, widget and public-link users.