RAG Chatbot
June 13, 2026 ยท View on GitHub
This directory contains the RAG (Retrieval-Augmented Generation) Chatbot example for the Atomic Agents project. This example demonstrates how to build an intelligent chatbot that uses document retrieval to provide context-aware responses using the Atomic Agents framework.
Features
- Document Chunking: Automatically splits documents into manageable chunks with configurable overlap
- Vector Storage: Supports both ChromaDB and Qdrant for efficient storage and retrieval of document chunks
- Semantic Search: Generates and executes semantic search queries to find relevant context
- Context-Aware Responses: Provides detailed answers based on retrieved document chunks
- Interactive UI: Rich console interface with progress indicators and formatted output
Getting Started
To get started with the RAG Chatbot:
-
Clone the main Atomic Agents repository:
git clone https://github.com/eigenwise/atomic-agents -
Navigate to the RAG Chatbot directory:
cd atomic-agents/atomic-examples/rag-chatbot -
Install the dependencies using uv:
uv sync -
Set up environment variables: Create a
.envfile in therag-chatbotdirectory with the following content:OPENAI_API_KEY=your_openai_api_key VECTOR_DB_TYPE=chroma # or 'qdrant'Replace
your_openai_api_keywith your actual OpenAI API key. -
Run the RAG Chatbot:
uv run python rag_chatbot/main.py
Vector Database Configuration
The RAG Chatbot supports two vector databases:
ChromaDB (Default)
- Local storage: Data is stored locally in the
chroma_db/directory - Configuration: Set
VECTOR_DB_TYPE=chromain your.envfile
Qdrant
- Local storage: Data is stored locally in the
qdrant_db/directory - Configuration: Set
VECTOR_DB_TYPE=qdrantin your.envfile
Usage
Using ChromaDB (Default)
export VECTOR_DB_TYPE=chroma
uv run python rag_chatbot/main.py
Using Qdrant (Local)
export VECTOR_DB_TYPE=qdrant
uv run python rag_chatbot/main.py
Components
1. Query Agent (agents/query_agent.py)
Generates semantic search queries based on user questions to find relevant document chunks.
2. QA Agent (agents/qa_agent.py)
Analyzes retrieved chunks and generates comprehensive answers to user questions.
3. Vector Database Services (services/)
- Base Service (
services/base.py): Abstract interface for vector database operations - ChromaDB Service (
services/chroma_db.py): ChromaDB implementation - Qdrant Service (
services/qdrant_db.py): Qdrant implementation - Factory (
services/factory.py): Creates the appropriate service based on configuration
4. Context Provider (context_providers.py)
Provides retrieved document chunks as context to the agents.
5. Main Script (main.py)
Orchestrates the entire process, from document processing to user interaction.
How It Works
-
The system initializes by:
- Downloading a sample document (State of the Union address)
- Splitting it into chunks with configurable overlap
- Storing chunks in the selected vector database with vector embeddings
-
For each user question:
- The Query Agent generates an optimized semantic search query
- Relevant chunks are retrieved from the vector database
- The QA Agent analyzes the chunks and generates a detailed answer
- The system displays the thought process and final answer
Customization
You can customize the RAG Chatbot by:
- Modifying chunk size and overlap in
config.py - Adjusting the number of chunks to retrieve for each query
- Using different documents as the knowledge base
- Customizing the system prompts for both agents
- Switching between ChromaDB and Qdrant by changing the
VECTOR_DB_TYPEenvironment variable
Example Usage
The chatbot can answer questions about the loaded document, such as:
- "What were the main points about the economy?"
- "What did the president say about healthcare?"
- "How did he address foreign policy?"
Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.