Skip to content

Commit 0593e5b

Browse files
committed
feat: Qdrant support
Signed-off-by: Anush008 <[email protected]>
1 parent 428f38a commit 0593e5b

File tree

15 files changed

+933
-399
lines changed

15 files changed

+933
-399
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
chroma_db/
2+
qdrant_db/

atomic-examples/rag-chatbot/README.md

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This directory contains the RAG (Retrieval-Augmented Generation) Chatbot example
55
## Features
66

77
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
8+
2. Vector Storage: Supports both [ChromaDB](https://www.trychroma.com/) and [Qdrant](https://qdrant.tech/) for efficient storage and retrieval of document chunks
99
3. Semantic Search: Generates and executes semantic search queries to find relevant context
1010
4. Context-Aware Responses: Provides detailed answers based on retrieved document chunks
1111
5. Interactive UI: Rich console interface with progress indicators and formatted output
@@ -15,73 +15,121 @@ This directory contains the RAG (Retrieval-Augmented Generation) Chatbot example
1515
To get started with the RAG Chatbot:
1616

1717
1. **Clone the main Atomic Agents repository:**
18+
1819
```bash
1920
git clone https://github.com/BrainBlend-AI/atomic-agents
2021
```
2122

2223
2. **Navigate to the RAG Chatbot directory:**
24+
2325
```bash
2426
cd atomic-agents/atomic-examples/rag-chatbot
2527
```
2628

2729
3. **Install the dependencies using Poetry:**
30+
2831
```bash
2932
poetry install
3033
```
3134

3235
4. **Set up environment variables:**
3336
Create a `.env` file in the `rag-chatbot` directory with the following content:
37+
3438
```env
3539
OPENAI_API_KEY=your_openai_api_key
40+
VECTOR_DB_TYPE=chroma # or 'qdrant'
3641
```
42+
3743
Replace `your_openai_api_key` with your actual OpenAI API key.
3844

3945
5. **Run the RAG Chatbot:**
46+
4047
```bash
4148
poetry run python rag_chatbot/main.py
4249
```
4350

51+
## Vector Database Configuration
52+
53+
The RAG Chatbot supports two vector databases:
54+
55+
### ChromaDB (Default)
56+
57+
- **Local storage**: Data is stored locally in the `chroma_db/` directory
58+
- **Configuration**: Set `VECTOR_DB_TYPE=chroma` in your `.env` file
59+
60+
### Qdrant
61+
62+
- **Local storage**: Data is stored locally in the `qdrant_db/` directory
63+
- **Configuration**: Set `VECTOR_DB_TYPE=qdrant` in your `.env` file
64+
65+
## Usage
66+
67+
### Using ChromaDB (Default)
68+
69+
```bash
70+
export VECTOR_DB_TYPE=chroma
71+
poetry run python rag_chatbot/main.py
72+
```
73+
74+
### Using Qdrant (Local)
75+
76+
```bash
77+
export VECTOR_DB_TYPE=qdrant
78+
poetry run python rag_chatbot/main.py
79+
```
80+
4481
## Components
4582

4683
### 1. Query Agent (`agents/query_agent.py`)
84+
4785
Generates semantic search queries based on user questions to find relevant document chunks.
4886

4987
### 2. QA Agent (`agents/qa_agent.py`)
88+
5089
Analyzes retrieved chunks and generates comprehensive answers to user questions.
5190

52-
### 3. ChromaDB Service (`services/chroma_db.py`)
53-
Manages the vector database for storing and retrieving document chunks.
91+
### 3. Vector Database Services (`services/`)
92+
93+
- **Base Service** (`services/base.py`): Abstract interface for vector database operations
94+
- **ChromaDB Service** (`services/chroma_db.py`): ChromaDB implementation
95+
- **Qdrant Service** (`services/qdrant_db.py`): Qdrant implementation
96+
- **Factory** (`services/factory.py`): Creates the appropriate service based on configuration
5497

5598
### 4. Context Provider (`context_providers.py`)
99+
56100
Provides retrieved document chunks as context to the agents.
57101

58102
### 5. Main Script (`main.py`)
103+
59104
Orchestrates the entire process, from document processing to user interaction.
60105

61106
## How It Works
62107

63108
1. The system initializes by:
64109
- Downloading a sample document (State of the Union address)
65110
- Splitting it into chunks with configurable overlap
66-
- Storing chunks in ChromaDB with vector embeddings
111+
- Storing chunks in the selected vector database with vector embeddings
67112

68113
2. For each user question:
69114
- The Query Agent generates an optimized semantic search query
70-
- Relevant chunks are retrieved from ChromaDB
115+
- Relevant chunks are retrieved from the vector database
71116
- The QA Agent analyzes the chunks and generates a detailed answer
72117
- The system displays the thought process and final answer
73118

74119
## Customization
75120

76121
You can customize the RAG Chatbot by:
122+
77123
- Modifying chunk size and overlap in `config.py`
78124
- Adjusting the number of chunks to retrieve for each query
79125
- Using different documents as the knowledge base
80126
- Customizing the system prompts for both agents
127+
- Switching between ChromaDB and Qdrant by changing the `VECTOR_DB_TYPE` environment variable
81128

82129
## Example Usage
83130

84131
The chatbot can answer questions about the loaded document, such as:
132+
85133
- "What were the main points about the economy?"
86134
- "What did the president say about healthcare?"
87135
- "How did he address foreign policy?"
-5.99 MB
Binary file not shown.
-100 Bytes
Binary file not shown.
-3.91 KB
Binary file not shown.
-5.37 MB
Binary file not shown.

0 commit comments

Comments
 (0)