Sphinx AI Assistant#
_sphinx_ai_assistant adds machine-friendly documentation artifacts and an
optional in-page assistant experience to a Sphinx HTML site. Its build-time
features include per-page Markdown and llms.txt generation; its browser
features include Markdown/PDF actions, AI-provider deep links, MCP integration,
and an optional assistant panel.
The extension is designed so the static-documentation features can be used without deploying a model backend.
Start with the smallest deployment#
extensions += [
"scikitplot._externals._sphinx_ext._sphinx_ai_assistant",
]
ai_assistant_enabled = True
ai_assistant_generate_markdown = True
ai_assistant_generate_llms_txt = True
The defaults already enable Markdown and llms.txt generation. The
assistant panel’s network/API mode is disabled by default, so enabling the
extension alone does not require a model credential.
Deployment levels#
A useful way to deploy the extension is incrementally:
staticGenerate Markdown/
llms.txtand expose local browser actions. No model backend is required.panel stubKeep
ai_assistant_panel_api_enabled = False. The panel UI can be tested without sending model requests.live panelSet
ai_assistant_panel_api_enabled = Trueand configure a server-side proxy URL. The browser sends the bounded request contract to that proxy; provider credentials remain server-side.review/contributionAdd the separately permissioned feedback/review and dataset-contribution services only when the deployment has an explicit storage/review policy.
Core configuration#
Setting |
Default |
Purpose |
|---|---|---|
|
|
Master switch. |
|
|
Places the launcher in |
|
|
Browser-side main-content selector. |
|
|
Adds theme-specific server-side content selectors. |
|
|
Generate canonical page Markdown after the HTML build. |
|
|
Generate a documentation |
|
|
Keep |
|
|
Enable live proxy-backed assistant requests. |
|
|
Proxy endpoint used by the live panel. |
|
|
Permit same-tab conversation persistence. |
|
|
Initial state of the per-tab remember switch. |
|
|
Optional distinct HTTPS origin for the isolated assistant frame. |
The extension has additional provider, endpoint-profile, UI, feedback, contribution and presentation settings. Configure only the capability being deployed; do not copy a large configuration block without understanding its trust boundary.
Canonical Markdown versus browser copy#
The extension intentionally has two Markdown representations:
generated
page.mdis a published build artifact and can be fetched by tools outside the browser;clipboard conversion is produced from the live DOM and is a convenience representation for the current tab.
Use the generated file as the canonical external retrieval target when both are
available. A browser blob: or clipboard result is not a stable published
URL.
Conversation persistence#
When panel persistence is enabled, remembered conversation state is scoped to
sessionStorage and therefore to the current browser tab. The reader can
override the site’s initial remember setting. Invalid or oversized stored
state is cleared rather than trusted.
Feedback ownership#
Do not confuse the assistant’s reviewed Q&A workflow with generic page feedback:
generic documentation-page feedback is owned by Sphinx Feedback;
assistant Q&A review/contribution uses the assistant proxy’s explicit review/contribution routes and separate permissions.
The browser should never imply that a local rating has been shared unless the reader has entered the explicit sharing workflow.
Troubleshooting#
- The static extension works but live chat does not
Confirm
ai_assistant_panel_api_enabledand the proxy URL. A browser should not be pointed directly at a provider API that requires a secret.- The wrong page content is exported
Adjust the theme preset or content selectors. Client-side and server-side selectors are distinct settings because they operate on different representations.
- You are also enabling ``_sphinx_llm``
Choose one owner for overlapping Markdown/
llms.txtpublication until the deployment has explicitly reconciled the two artifact pipelines. Do not rely on extension ordering to resolve two writers targeting the same output name.