Files
2026-05-27 14:37:14 +00:00

48 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RAG Agent with Qdrant and Ollama
## Overview
This repository contains a minimal implementation of an AI agent that uses **RAG (RetrievalAugmented Generation)** with a local vector store powered by **Qdrant** and embeddings from **Ollama**. The agent can:
1. Add documents to the knowledge base.
2. Search the knowledge base semantically.
3. Answer arbitrary user queries using the stored information.
The project is structured into three main files:
- `main.py` entry point with an interactive CLI and examples.
- `tools.py` LangChain tools for adding/searching documents.
- `requirements.txt` Python dependencies.
## Installation
```bash
# Pull required Ollama models (run once)
ollama pull llama3
ollama pull nomic-embed-text
# Install Python packages
pip install -r requirements.txt
```
## Usage
Run the interactive client:
```bash
python main.py
```
You can use the following commands:
- `/add` add a new document.
- `/search <query>` perform a semantic search.
- `/quit` exit.
- Any other text is treated as a question for the agent.
## Architecture
The agent uses LangChains `create_agent` with two custom tools:
1. **add_to_knowledge_base** splits input into chunks, embeds them via Ollama, and stores in Qdrant.
2. **search_knowledge_base** performs a similarity search on the vector store.
The LLM is an Ollama `llama3` model accessed through LangChains `ChatOllama`. The embeddings are provided by `OllamaEmbeddings` with the `nomic-embed-text` model.
## Extending
Feel free to add more tools or integrate a persistent Qdrant instance instead of an inmemory one. The code is intentionally simple for educational purposes.