# docbot





> 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 docbotfrom 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}")# index documentation
docbot index ./docs
# start interactive session
docbot chat ./docs
# single question
docbot ask ./docs "What are the API rate limits?"Main class for the documentation chatbot.
Parameters:
docs_path(str): Path to documentation directorymodel(str): LLM model to use for answerschunk_size(int): Size of text chunks for indexing
Methods:
Index documentation files for retrieval.
bot.index(file_patterns=["*.md", "*.rst"])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 the current index.
bot.clear_index()Object returned by ask() method.
Attributes:
answer(str): Generated answer to the questionsources(list): List of source documents usedconfidence(float): Confidence score between 0 and 1
- 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
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_hereprs welcome. open an issue first for big changes.
MIT