AI Knowledge
Generate structured JSON exports from documentation for LLM consumption and RAG pipelines.
Overview
The knowledge system transforms MDX documentation into two JSON exports:
sections.json— Header-scoped sections for RAG pipelines and semantic searchpages.json— Full page content for LLM context windows and OpenWebUI upload
Content processing includes:
- Replacing
<TypeDocProps />components with JSON property documentation - Inlining demo source code from referenced demo files
- Converting theme tables to JSON data
- Resolving relative imports and links
Generation runs automatically during buildStart (production builds) and configureServer (dev server initialization). The knowledge field on QuiDocsConfig enables generation — no enabled flag is required.
Configuration
Define the knowledge field in your qui-docs.config.ts:
import type {QuiDocsConfig} from "@qualcomm-ui/mdx-vite"
import {readFileSync} from "node:fs"
import {resolve} from "node:path"
export default {
knowledge: {
baseUrl: "https://docs.example.com",
exclude: ["**/internal/**", "*guide+/swagger*"],
extraFiles: [
{
contents: readFileSync(
resolve(__dirname, "../some-package/CHANGELOG.md"),
"utf-8",
),
id: "changelog",
},
],
},
} satisfies QuiDocsConfigKnowledgeConfig
| Prop | Type | Default |
|---|---|---|
Base URL for documentation links in the generated output. | string | |
Glob patterns to exclude, relative to the resolved page directory. Supports
full glob syntax via minimatch. | string[] | |
exclude: ['**/internal/**', 'guide/drafts/*', '*.draft.mdx'] | ||
Extra files to include in knowledge output beyond the generated page content. | KnowledgeExtraFile[] | |
Configuration for which frontmatter fields to include in the generated
Markdown output. Uses glob patterns for flexible field selection. | ||
Platform-specific integration configurations for uploading generated
knowledge to external services. | { | |
Output directory for generated knowledge files, relative to the public dir. | string | 'exports' |
Prefix to use for page IDs. Used to generate unique page IDs for knowledgebases
that span multiple QUI Docs sites with potentially overlapping routes. | string | |
`table-` | ||
Configuration for whole-page JSON exports. | ||
Configuration for header-scoped section exports. | ||
stringstring[]
exclude: ['**/internal/**', 'guide/drafts/*', '*.draft.mdx']
KnowledgeExtraFile[]
{
openWebUi?: Array<{
envFile?: string
id: string
}>
}
stringstring`table-`KnowledgeExtraFile
| Prop | Type |
|---|---|
The Markdown content for this file. | string |
Unique identifier for this file, used for the output filename. | string |
Whether to process this file as MDX content, replacing relative URLs, and
applying other transformations as if the file were authored as mdx
documentation. | boolean |
Display title for this content. | string |
stringstringbooleanstringKnowledgeFrontmatterConfig
SectionExportConfig
| Prop | Type | Default |
|---|---|---|
Header depths that define section boundaries. | number[] | [1, 2, 3] |
Minimum content length to create a section entry. | number | 0 |
Output path for sections.json, relative to the public directory. | string | 'sections.json' |
number[]
numberstringPagesExportConfig
| Prop | Type | Default |
|---|---|---|
Output path for pages.json, relative to the public directory. | string | 'pages.json' |
stringOutput Structure
Generated files are written to {publicDir}/{outputPath}/. The default output path is exports.
sections.json
Contains header-scoped section entries extracted from each documentation page. Each section includes a breadcrumb header path, prose content, code examples, and an MD5 hash for change detection.
Intended for RAG pipelines and semantic search. Sections are scoped by heading depth (default: h1, h2, h3), producing granular chunks suitable for embedding and retrieval.
KnowledgeSections
| Prop | Type |
|---|---|
string | |
string | |
SectionEntry[] | |
number | |
1 |
stringstringSectionEntry[]
number1SectionEntry
| Prop | Type |
|---|---|
Code examples extracted from this section. | Array<{ |
Prose content with code blocks removed. Used for formatted output. | string |
Hash of this section's contents. Includes codeExamples, metadata, headerPath, and rawContent. | string |
Breadcrumb path of headers leading to this section. | string[] |
["Button", "Examples", "Variants"] | |
Depth of this section's heading (1-6). Matches the heading that starts
this section (e.g. an h2 section has headingLevel 2). | number |
Frontmatter from the source page. | Record< |
Source page identifier. | string |
Raw markdown content from the AST, including code blocks. | string |
Generated section ID for anchor links. | string |
"button-examples-variants" | |
Search terms extracted from ::: terms ::: blocks within this section. | string[] |
Name of the types or interfaces described by typeDocProps in this section. | Array<{ |
URL with anchor to this specific section. | string |
Array<{
code: string
language: string
}>
stringstringstring[]
["Button", "Examples", "Variants"]
numberRecord<
string,
unknown
>
stringstringstring"button-examples-variants"string[]
Array<{
props: Array<{
defaultValue?: string
description: string
name: string
propType?:
| 'input'
| 'output'
required: boolean
type: string
}>
type: string
}>
stringpages.json
Contains the full rendered markdown content of each documentation page. Each entry includes the page title, route pathname, and an MD5 hash.
Used by the page header UI for copy/download actions and by the upload-knowledge CLI for OpenWebUI uploads.
KnowledgePages
| Prop | Type |
|---|---|
string | |
string | |
PageEntry[] | |
number | |
1 |
PageEntry
Page Header UI
When knowledge is configured, each documentation page displays two actions in the page header:
- Copy Page — Copies the page content as Markdown to the clipboard
- Download Page — Downloads the page as a
.mdfile
Both actions fetch content from pages.json at runtime. They only appear on pages that have a corresponding entry in the generated output.
OpenWebUI Integration
Upload generated knowledge to OpenWebUI instances. The upload command auto-detects pages.json in the output directory and uploads each page as an individual file.
Configuration
Define integrations in the knowledge.integrations.openWebUi array:
export default {
knowledge: {
baseUrl: "https://docs.example.com",
integrations: {
openWebUi: [{id: "production"}, {id: "staging", envFile: ".env.staging"}],
},
},
} satisfies QuiDocsConfigEach integration loads credentials from an env file. By convention, an integration with id: "production" loads .env.production. Override this with the envFile property.
OpenWebUiIntegration
Credential Environment Variables
Required variables in each env file:
| Variable | Fallback | Description |
|---|---|---|
OPEN_WEB_UI_URL | WEB_UI_URL | OpenWebUI instance URL |
OPEN_WEB_UI_API_KEY | WEB_UI_KEY | API key for authentication |
OPEN_WEB_UI_KNOWLEDGE_ID | KNOWLEDGE_ID | Target knowledge base ID |
Upload Command
# Upload to all configured integrations
qui-mdx-vite upload-knowledge
# Upload to specific integrations
qui-mdx-vite upload-knowledge -i production,staging
# Override the knowledge file path
qui-mdx-vite upload-knowledge -p ./custom/exports
# Force upload even if content unchanged
qui-mdx-vite upload-knowledge --forceCLI Options
| Option | Description |
|---|---|
-p, --path <path> | Override knowledge file path |
-i, --integration <names> | Comma-separated integrations to upload to |
--force | Force upload even if content unchanged |
When no integrations are configured, the upload command falls back to credentials from OPEN_WEB_UI_* environment variables.