Skip to content

2aronS/docbot

Repository files navigation

# docbot

![license](https://img.shields.io/badge/license-MIT-blue)
![status](https://img.shields.io/badge/status-active-brightgreen)
![python](https://img.shields.io/badge/python-3.9+-blue)
![code style](https://img.shields.io/badge/code%20style-black-black)
![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen)

> AI assistant that answers questions from your documentation

## table of contents

- [install](#install)
- [usage](#usage)
- [api](#api)
- [features](#features)
- [configuration](#configuration)
- [contributing](#contributing)
- [license](#license)

## install

```bash
pip install docbot

usage

from docbot import DocBot

# initialize with your documentation directory
bot = DocBot(docs_path="./docs")

# index your documentation
bot.index()

# ask questions
response = bot.ask("How do I configure authentication?")
print(response.answer)
print(f"Sources: {response.sources}")

cli usage

# index documentation
docbot index ./docs

# start interactive session
docbot chat ./docs

# single question
docbot ask ./docs "What are the API rate limits?"

api

DocBot(docs_path, model="gpt-3.5-turbo", chunk_size=512)

Main class for the documentation chatbot.

Parameters:

  • docs_path (str): Path to documentation directory
  • model (str): LLM model to use for answers
  • chunk_size (int): Size of text chunks for indexing

Methods:

index(file_patterns=["*.md", "*.txt"])

Index documentation files for retrieval.

bot.index(file_patterns=["*.md", "*.rst"])

ask(question, max_sources=3)

Ask a question and get an answer with sources.

response = bot.ask("How do I install the package?", max_sources=5)

Returns: Response object with answer and sources attributes.

clear_index()

Clear the current index.

bot.clear_index()

Response

Object returned by ask() method.

Attributes:

  • answer (str): Generated answer to the question
  • sources (list): List of source documents used
  • confidence (float): Confidence score between 0 and 1

features

  • Multiple formats: Supports Markdown, reStructuredText, plain text
  • Vector search: Uses embeddings for semantic document retrieval
  • Source attribution: Shows which docs were used for each answer
  • Local or cloud: Run with local models or OpenAI/Anthropic APIs
  • Incremental indexing: Only re-index changed files

configuration

Create a docbot.yaml file in your project root:

model: gpt-4
chunk_size: 512
overlap: 50
embedding_model: text-embedding-ada-002
max_sources: 3
file_patterns:
  - "*.md"
  - "*.rst"
  - "docs/**/*.txt"

Or set environment variables:

export DOCBOT_MODEL=gpt-4
export DOCBOT_CHUNK_SIZE=512
export OPENAI_API_KEY=your_key_here

contributing

prs welcome. open an issue first for big changes.

license

MIT

About

AI assistant that answers questions from your documentation

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors