This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
# Agent with RAG Memory
|
||||
# RAG Agent with LangChain, Qdrant, and Ollama
|
||||
|
||||
This project demonstrates a simple RAG (Retrieval-Augmented Generation) agent that uses LangChain tools to perform basic operations via an interactive command line interface (CLI).
|
||||
This repository contains a minimal example of a Retrieval-Augmented Generation (RAG) agent built with **LangChain**, **Qdrant**, and **Ollama**. The agent retrieves relevant documents from a local Qdrant vector store and generates answers using an Ollama language model.
|
||||
|
||||
## Features
|
||||
## Prerequisites
|
||||
|
||||
- **Add Numbers** – Add two integers using the `add_numbers` tool.
|
||||
- **Search Items** – Search a predefined list of strings for a query using the `search_item` tool.
|
||||
- **Interactive CLI** – Use `/add`, `/search`, and `/quit` commands to interact with the agent.
|
||||
- **Python 3.10+**
|
||||
- **Qdrant** server running locally (default port `6333`).
|
||||
- Create a collection named `rag_collection` and populate it with embeddings.
|
||||
- **Ollama** server running locally (default port `11434`).
|
||||
- Ensure the model `llama3.1` (or any other supported model) is available.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -17,7 +19,7 @@ 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`
|
||||
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
|
||||
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
@@ -25,72 +27,34 @@ pip install -r requirements.txt
|
||||
|
||||
## Usage
|
||||
|
||||
Run the CLI:
|
||||
|
||||
```bash
|
||||
python -m src.main
|
||||
```
|
||||
|
||||
You will see a prompt:
|
||||
|
||||
```
|
||||
Welcome to the RAG Agent CLI!
|
||||
Available commands:
|
||||
/add <int> <int> - Add two numbers.
|
||||
/search <query> - Search items in memory.
|
||||
/quit - Exit the program.
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
- **/add**
|
||||
Add two integers.
|
||||
|
||||
```text
|
||||
>> /add 5 7
|
||||
Result: 12
|
||||
```
|
||||
|
||||
- **/search**
|
||||
Search the internal memory for a query string.
|
||||
|
||||
```text
|
||||
>> /search python
|
||||
Matches found:
|
||||
1. Python programming
|
||||
```
|
||||
|
||||
- **/quit**
|
||||
Exit the program.
|
||||
|
||||
```text
|
||||
>> /quit
|
||||
Goodbye!
|
||||
```
|
||||
You will be prompted to enter a question. The agent will retrieve relevant documents from Qdrant and generate an answer using Ollama. Type `exit` or `quit` to terminate the program.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
agent-s-rag-pamyatyu/
|
||||
├── src/
|
||||
│ ├── __init__.py
|
||||
│ ├── cli.py
|
||||
│ ├── main.py
|
||||
│ └── tools.py
|
||||
├── README.md
|
||||
├── requirements.txt
|
||||
└── pyproject.toml
|
||||
├── src/
|
||||
│ └── main.py
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
- `requirements.txt` – lists all Python dependencies, including `langchain-qdrant` and `langchain-ollama`.
|
||||
- `src/main.py` – contains the RAG agent implementation.
|
||||
- `README.md` – this documentation file.
|
||||
|
||||
- `langchain` – The core library for building language model agents.
|
||||
- `python-dotenv` – (Optional) For loading environment variables if needed.
|
||||
## Troubleshooting
|
||||
|
||||
- **Missing dependencies**: Ensure you ran `pip install -r requirements.txt`.
|
||||
- **Qdrant connection errors**: Verify Qdrant is running and the collection name matches `rag_collection`.
|
||||
- **Ollama connection errors**: Verify Ollama is running and the model name is correct.
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
This project is provided as-is for educational purposes. Feel free to modify and extend it.
|
||||
|
||||
---
|
||||
|
||||
Feel free to extend the tools or the CLI to suit your needs!
|
||||
---
|
||||
Reference in New Issue
Block a user