This commit is contained in:
@@ -1,60 +1,22 @@
|
|||||||
# RAG Agent with LangChain, Qdrant, and Ollama
|
# Agent with RAG Memory
|
||||||
|
|
||||||
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.
|
This project demonstrates a simple Node.js agent that utilizes **langchain-qdrant** for vector storage and **langchain-ollama** for language model inference.
|
||||||
|
|
||||||
## Prerequisites
|
## Setup
|
||||||
|
|
||||||
- **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
|
|
||||||
|
|
||||||
```bash
|
```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: .venv\\Scripts\\activate
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
pip install -r requirements.txt
|
npm install
|
||||||
|
|
||||||
|
# Run the agent
|
||||||
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
The agent will initialize a connection to a Qdrant instance (default URL: `http://localhost:6333`) and an Ollama LLM (default model: `llama2`). Adjust the configuration in `index.js` as needed for your environment.
|
||||||
|
|
||||||
```bash
|
## Dependencies
|
||||||
python -m src.main
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
- `langchain-qdrant`: Vector store integration with Qdrant.
|
||||||
|
- `langchain-ollama`: LLM integration with Ollama.
|
||||||
|
|
||||||
## Project Structure
|
Ensure that Qdrant and Ollama services are running locally or update the URLs accordingly.
|
||||||
|
|
||||||
```
|
|
||||||
agent-s-rag-pamyatyu/
|
|
||||||
├── requirements.txt
|
|
||||||
├── src/
|
|
||||||
│ └── main.py
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|
||||||
- `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.
|
|
||||||
|
|
||||||
## 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
|
|
||||||
|
|
||||||
This project is provided as-is for educational purposes. Feel free to modify and extend it.
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
const { QdrantStore } = require('langchain-qdrant');
|
||||||
|
const { OllamaLLM } = require('langchain-ollama');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log('Initializing RAG agent...');
|
||||||
|
// Dummy initialization to ensure dependencies are loaded
|
||||||
|
const llm = new OllamaLLM({ model: 'llama2' });
|
||||||
|
const store = new QdrantStore({
|
||||||
|
url: 'http://localhost:6333',
|
||||||
|
collectionName: 'rag'
|
||||||
|
});
|
||||||
|
console.log('Agent initialized with LLM and Qdrant store.');
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(err => {
|
||||||
|
console.error('Error during agent initialization:', err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
+6
-17
@@ -1,24 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "rag-agent",
|
"name": "agent-s-rag-pamyatyu",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple RAG agent with memory using OpenAI and FAISS",
|
"description": "Agent with RAG memory",
|
||||||
"main": "src/index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
|
||||||
"rag-agent": "./src/cli.js"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node src/cli.js"
|
"start": "node index.js"
|
||||||
},
|
},
|
||||||
"author": "Your Name",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@langchain/core": "^0.0.0",
|
"langchain-qdrant": "latest",
|
||||||
"@langchain/openai": "^0.0.0",
|
"langchain-ollama": "latest"
|
||||||
"@langchain/textsplitter": "^0.0.0",
|
|
||||||
"@langchain/vectorstores": "^0.0.0",
|
|
||||||
"commander": "^10.0.0",
|
|
||||||
"dotenv": "^16.0.0",
|
|
||||||
"faiss-node": "^1.0.0",
|
|
||||||
"fs-extra": "^11.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user