58 lines
1.4 KiB
Markdown
58 lines
1.4 KiB
Markdown
# RAG Agent with Qdrant + Ollama
|
|
|
|
## Stack
|
|
- Python 3.10+
|
|
- Qdrant — vector database
|
|
- Ollama — local LLM and embeddings (`llama3`, `nomic-embed-text`)
|
|
- LangChain — agent and RAG framework
|
|
|
|
## Setup
|
|
|
|
### 1. Pull Ollama models
|
|
```bash
|
|
ollama pull llama3
|
|
ollama pull nomic-embed-text
|
|
```
|
|
|
|
### 2. Start Qdrant
|
|
```bash
|
|
docker run -p 6333:6333 qdrant/qdrant
|
|
```
|
|
|
|
### 3. Install Python dependencies
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Initialize knowledge base from a directory
|
|
```bash
|
|
python init_knowledge_base.py ./docs
|
|
```
|
|
Loads all `.txt` and `.md` files from the given directory into the vector store.
|
|
|
|
### Run the interactive client
|
|
```bash
|
|
python client.py
|
|
```
|
|
|
|
### Client commands
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `/add <title> \| <content>` | Add a document to the knowledge base |
|
|
| `/search <query>` | Semantic search in the knowledge base |
|
|
| `/quit` | Exit the client |
|
|
| `<any text>` | Send a question to the RAG agent |
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── vector_store.py # Qdrant + Ollama embeddings + chunking
|
|
├── tools.py # @tool: search_knowledge_base, add_to_knowledge_base
|
|
├── agent.py # create_react_agent with RAG tools
|
|
├── init_knowledge_base.py # Load documents from directory
|
|
├── client.py # Interactive CLI client
|
|
└── requirements.txt
|
|
``` |