MkDocs Gemini Chatbot Plugin
An MkDocs plugin that adds a conversational chatbot to your documentation site, powered by Google's Gemini models. The chatbot uses the entire content of your documentation, including auto-generated API references, to provide intelligent, context-aware answers with precise, clickable links to the relevant sections.
- Conversational AI: Uses Google's Gemini models to understand and answer user questions.
- Full-Site Context: Indexes the content of your entire MkDocs site, including pages generated by other plugins like
mkdocstrings. - Precision Linking: Automatically creates clickable links to the exact section or page being referenced in its answers.
- Responsive Design: A clean, modern UI that works beautifully on both desktop and mobile, with a fullscreen mode for immersive conversations.
- Light & Dark Mode: Automatically adapts its theme to your MkDocs Material theme's color palette.
- Code-Friendly: Renders Markdown responses, with syntax highlighting and a "Copy" button for code blocks.
- Persistent History: Remembers your conversation history within a browser session.
- Secure API Key Handling: Loads your Gemini API key securely from a
.envfile, so you never have to commit it to your repository.
Installation
-
Install the plugin from PyPI:
pip install mkdocs-gemini-chatbot
-
Get a Gemini API Key:
- Go to Google AI Studio.
- Click on "Get API key" and create a new key.
-
Set up your environment:
-
Create a file named
.envin the root of your MkDocs project (where yourmkdocs.ymlfile is). -
Add your API key to the
.envfile:GEMINI_API_KEY="your-secret-api-key-here" -
Important: Add the
.envfile to your.gitignoreto keep your key secure.
-
Configuration
In your mkdocs.yml file, add gemini-chatbot to your plugins list. No further configuration is needed if you are using a .env file.
site_name: My Awesome Docs
plugins:
- search
- mkdocstrings
- gemini-chatbot # That's it!
Advanced Configuration
You can customize the chatbot's behavior by adding options under the plugin entry:
plugins:
- gemini-chatbot:
# Optional: Override the .env file (not recommended)
# gemini_api_key: "your-key-here"
# Optional: Change the Gemini model used
model: "gemini-1.5-pro"
# Optional: Customize the chat window title
chat_title: "Ask our AI Assistant"
# Optional: Set a custom initial greeting
initial_prompt: "I'm an AI assistant for these docs. How can I help?"
How It Works
The plugin works by hooking into the MkDocs build process.
- During the build, it processes the final rendered HTML of every page.
- It intelligently extracts all text content and finds all linkable anchors (e.g.,
#section-name) created by MkDocs andmkdocstrings. - This content and anchor information is saved to a
content.jsonfile in your builtsitedirectory. - When a user asks a question, the chatbot sends the user's query, the conversation history, and the entire site's context to the Gemini API, with specific instructions to use the anchors for precision linking.
This ensures that the AI has the most complete and accurate context to answer questions about your documentation.
Metadata
Release files for mkdocs-gemini-chatbot 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mkdocs_gemini_chatbot-1.0.1.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mkdocs_gemini_chatbot-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.0 kB
Release files / mkdocs_gemini_chatbot-1.0.1.tar.gz
| Download URL | mkdocs_gemini_chatbot-1.0.1.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
942f41442da2e09b013ad81614ce3f83fc4547d95f19046100f348373fc6a210
|
|
BLAKE2b-256 checksum How to use checksums |
e9bc656f697db76d22263b51109338618dcc093ed98b8da6c337005c2b03c49a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / mkdocs_gemini_chatbot-1.0.1-py3-none-any.whl
| Download URL | mkdocs_gemini_chatbot-1.0.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ad1016cea92f0c7646f7d489170ca7da2be78172c7462f5138bab33a1b111d1
|
|
BLAKE2b-256 checksum How to use checksums |
12823233e36944ec0c4042f23d14219833e7452fbb74139b99e567d316a94465
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|