64 lines
1.5 KiB
Markdown
64 lines
1.5 KiB
Markdown
# Agent with RAG Memory using Qdrant and Ollama
|
|
|
|
This project demonstrates a simple Retrieval-Augmented Generation (RAG) agent built with LangChain, Qdrant, and Ollama. The agent uses Ollama embeddings for vector representation and Qdrant as the vector store.
|
|
|
|
## Prerequisites
|
|
|
|
- Python 3.10+
|
|
- Qdrant server running locally or accessible remotely
|
|
- Ollama server running locally or accessible remotely
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
# Clone the repository
|
|
git clone https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu.git
|
|
cd agent-s-rag-pamyatyu
|
|
|
|
# Create a virtual environment (optional but recommended)
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows use `venv\Scripts\activate`
|
|
|
|
# Install dependencies
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Edit `config.py` to match your environment:
|
|
|
|
```python
|
|
# Qdrant settings
|
|
QDRANT_HOST = "localhost"
|
|
QDRANT_PORT = 6333
|
|
QDRANT_API_KEY = None
|
|
QDRANT_COLLECTION = "rag_collection"
|
|
|
|
# Ollama settings
|
|
OLLAMA_MODEL = "llama3"
|
|
```
|
|
|
|
## Running the Agent
|
|
|
|
```bash
|
|
python src/main.py
|
|
```
|
|
|
|
The script will:
|
|
|
|
1. Connect to Qdrant.
|
|
2. Create an Ollama embeddings instance.
|
|
3. Add sample documents to the collection if it is empty.
|
|
4. Build a RetrievalQA chain using the Ollama LLM.
|
|
5. Execute a sample query and print the answer.
|
|
|
|
## Extending
|
|
|
|
- Replace the sample documents with your own corpus.
|
|
- Adjust the `chain_type` in `src/agent.py` if you need a different retrieval strategy.
|
|
- Use environment variables or a `.env` file to store sensitive information like `QDRANT_API_KEY`.
|
|
|
|
## License
|
|
|
|
MIT License
|
|
--- |