Skip to content

Commit fa7fe45

Browse files
Add simple RAG example
1 parent 5697bdf commit fa7fe45

File tree

11 files changed

+4130
-1
lines changed

11 files changed

+4130
-1
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,20 @@ This snippet showcases how to create a customizable agent that responds to user
152152

153153
In addition to the quickstart examples, we have more complex examples demonstrating the power of Atomic Agents:
154154

155+
- [Basic Multimodal](/atomic-examples/basic-multimodal/README.md): Demonstrates how to analyze images with text, focusing on extracting structured information from nutrition labels using GPT-4 Vision capabilities.
156+
157+
- [Deep Research](/atomic-examples/deep-research/README.md): An advanced example showing how to perform deep research tasks.
158+
159+
- [Orchestration Agent](/atomic-examples/orchestration-agent/README.md): Shows how to create an Orchestrator Agent that intelligently decides between using different tools (search or calculator) based on user input.
160+
161+
- [RAG Chatbot](/atomic-examples/rag-chatbot/README.md): A chatbot implementation using Retrieval-Augmented Generation (RAG) to provide context-aware responses.
162+
155163
- [Web Search Agent](/atomic-examples/web-search-agent/README.md): An intelligent agent that performs web searches and answers questions based on the results.
156164

157165
- [YouTube Summarizer](/atomic-examples/youtube-summarizer/README.md): An agent that extracts and summarizes knowledge from YouTube videos.
158166

167+
- [YouTube to Recipe](/atomic-examples/youtube-to-recipe/README.md): An example that extracts structured recipe information from cooking videos, demonstrating complex information extraction and structuring.
168+
159169
For a complete list of examples, see the [examples directory](/atomic-examples/).
160170

161171
These examples provide a great starting point for understanding and using Atomic Agents.
@@ -262,7 +272,6 @@ from web_search_agent.tools.another_search import AnotherSearchTool
262272
# Update the output schema
263273
query_agent.config.output_schema = AnotherSearchTool.input_schema
264274
```
265-
266275
This design pattern simplifies the process of chaining agents and tools, making your AI applications more adaptable and easier to maintain.
267276

268277
## Running the CLI
@@ -339,3 +348,4 @@ This project is licensed under the MIT License—see the [LICENSE](LICENSE) file
339348
## Star History
340349

341350
[![Star History Chart](https://api.star-history.com/svg?repos=BrainBlend-AI/atomic-agents&type=Date)](https://star-history.com/#BrainBlend-AI/atomic-agents&Date)
351+

atomic-examples/rag-chatbot/README.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# RAG Chatbot
2+
3+
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.
4+
5+
## Features
6+
7+
1. Document Chunking: Automatically splits documents into manageable chunks with configurable overlap
8+
2. Vector Storage: Uses ChromaDB for efficient storage and retrieval of document chunks
9+
3. Semantic Search: Generates and executes semantic search queries to find relevant context
10+
4. Context-Aware Responses: Provides detailed answers based on retrieved document chunks
11+
5. Interactive UI: Rich console interface with progress indicators and formatted output
12+
13+
## Getting Started
14+
15+
To get started with the RAG Chatbot:
16+
17+
1. **Clone the main Atomic Agents repository:**
18+
```bash
19+
git clone https://github.com/BrainBlend-AI/atomic-agents
20+
```
21+
22+
2. **Navigate to the RAG Chatbot directory:**
23+
```bash
24+
cd atomic-agents/atomic-examples/rag-chatbot
25+
```
26+
27+
3. **Install the dependencies using Poetry:**
28+
```bash
29+
poetry install
30+
```
31+
32+
4. **Set up environment variables:**
33+
Create a `.env` file in the `rag-chatbot` directory with the following content:
34+
```env
35+
OPENAI_API_KEY=your_openai_api_key
36+
```
37+
Replace `your_openai_api_key` with your actual OpenAI API key.
38+
39+
5. **Run the RAG Chatbot:**
40+
```bash
41+
poetry run python rag_chatbot/main.py
42+
```
43+
44+
## Components
45+
46+
### 1. Query Agent (`agents/query_agent.py`)
47+
Generates semantic search queries based on user questions to find relevant document chunks.
48+
49+
### 2. QA Agent (`agents/qa_agent.py`)
50+
Analyzes retrieved chunks and generates comprehensive answers to user questions.
51+
52+
### 3. ChromaDB Service (`services/chroma_db.py`)
53+
Manages the vector database for storing and retrieving document chunks.
54+
55+
### 4. Context Provider (`context_providers.py`)
56+
Provides retrieved document chunks as context to the agents.
57+
58+
### 5. Main Script (`main.py`)
59+
Orchestrates the entire process, from document processing to user interaction.
60+
61+
## How It Works
62+
63+
1. The system initializes by:
64+
- Downloading a sample document (State of the Union address)
65+
- Splitting it into chunks with configurable overlap
66+
- Storing chunks in ChromaDB with vector embeddings
67+
68+
2. For each user question:
69+
- The Query Agent generates an optimized semantic search query
70+
- Relevant chunks are retrieved from ChromaDB
71+
- The QA Agent analyzes the chunks and generates a detailed answer
72+
- The system displays the thought process and final answer
73+
74+
## Customization
75+
76+
You can customize the RAG Chatbot by:
77+
- Modifying chunk size and overlap in `config.py`
78+
- Adjusting the number of chunks to retrieve for each query
79+
- Using different documents as the knowledge base
80+
- Customizing the system prompts for both agents
81+
82+
## Example Usage
83+
84+
The chatbot can answer questions about the loaded document, such as:
85+
- "What were the main points about the economy?"
86+
- "What did the president say about healthcare?"
87+
- "How did he address foreign policy?"
88+
89+
## Contributing
90+
91+
Contributions are welcome! Please fork the repository and submit a pull request with your enhancements or bug fixes.
92+
93+
## License
94+
95+
This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details.

0 commit comments

Comments
 (0)