Skip to main content

A MkDocs plugin to add a Gemini-powered chatbot to your documentation site.

Project description

MkDocs Gemini Chatbot Plugin

PyPI version

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.

Chatbot Demo ## Features

  • 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 .env file, so you never have to commit it to your repository.

Installation

  1. Install the plugin from PyPI:

    pip install mkdocs-gemini-chatbot
    
  2. Get a Gemini API Key:

  3. Set up your environment:

    • Create a file named .env in the root of your MkDocs project (where your mkdocs.yml file is).

    • Add your API key to the .env file:

      GEMINI_API_KEY="your-secret-api-key-here"
      
    • Important: Add the .env file to your .gitignore to 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.

  1. During the build, it processes the final rendered HTML of every page.
  2. It intelligently extracts all text content and finds all linkable anchors (e.g., #section-name) created by MkDocs and mkdocstrings.
  3. This content and anchor information is saved to a content.json file in your built site directory.
  4. 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_gemini_chatbot-1.0.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_gemini_chatbot-1.0.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_gemini_chatbot-1.0.0.tar.gz.

File metadata

  • Download URL: mkdocs_gemini_chatbot-1.0.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mkdocs_gemini_chatbot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d840f16cbe8879fd452eed289ced10040756dcda01531802543cfbe8a2310d2d
MD5 3fa5118d9f4220aa4c35de129cac25c8
BLAKE2b-256 24a46afcd41f89f62ea9a46fba52eb7ea6660e4d0c7e94e0869b7730f8560e28

See more details on using hashes here.

File details

Details for the file mkdocs_gemini_chatbot-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_gemini_chatbot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa6a6b246134a462d19e8a338dbe4553eaa201b815e7e9dbe1898d41cd0ba0ba
MD5 ea143428e7f0b6443b2096d8a303b799
BLAKE2b-256 071a4d62bfe35f488b5fe0002bfde94c1b424deb7c75d28a283645b3ebb7aea6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page