MkDocs plugin to generate an /llms.txt file.
Project description
mkdocs-llmstxt
MkDocs plugin to generate an /llms.txt file.
/llms.txt - A proposal to standardise on using an /llms.txt file to provide information to help LLMs use a website at inference time.
See our own dynamically generated /llms.txt as a demonstration.
Installation
pip install mkdocs-llmstxt
Usage
Enable the plugin in mkdocs.yml
:
plugins:
- llmstxt:
files:
- output: llms.txt
inputs:
- file1.md
- folder/file2.md
You can generate several files, each from its own set of input files.
File globbing is supported:
plugins:
- llmstxt:
files:
- output: llms.txt
inputs:
- file1.md
- reference/*/*.md
The plugin will concatenate the rendered HTML of these input pages, clean it up a bit (with BeautifulSoup), convert it back to Markdown (with Markdownify), and format it (with Mdformat). By concatenating HTML instead of Markdown, we ensure that dynamically generated contents (API documentation, executed code blocks, snippets from other files, Jinja macros, etc.) are part of the generated text files. Credits to Petyo Ivanov for the original idea ✨
You can disable auto-cleaning of the HTML:
plugins:
- llmstxt:
autoclean: false
You can also pre-process the HTML before it is converted back to Markdown:
plugins:
- llmstxt:
preprocess: path/to/script.py
The specified script.py
must expose a preprocess
function that accepts the soup
and output
arguments:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from bs4 import BeautifulSoup
def preprocess(soup: BeautifulSoup, output: str) -> None:
... # modify the soup
The output
argument lets you modify the soup depending on which file is being generated.
Have a look at our own pre-processing function to get inspiration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_llmstxt-0.1.0.tar.gz
.
File metadata
- Download URL: mkdocs_llmstxt-0.1.0.tar.gz
- Upload date:
- Size: 37.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e77bd5b4ecdc57cba9a92faceab5ba4cdffa4d2a0a78ebc1823ca3cde3fc108 |
|
MD5 | c191f907bfc8f42107d6b5ddb2cac720 |
|
BLAKE2b-256 | 56b12c5b7a36dcb5e8cc9e220dc8c9eb5407be1d1a09d869275a46da9a808d5d |
File details
Details for the file mkdocs_llmstxt-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_llmstxt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 893870a0060d0fc0690f03a519652932929225499cbacd6377e45e0c48041865 |
|
MD5 | 834e867341b9303115c814070f3b7eac |
|
BLAKE2b-256 | 588019ba3d680da50a6e2b09deaeedc004ed6bac3615f0ff68112e3f785b7c98 |