Files
agent-s-rag-pamyatyu/README.md
T
2026-06-30 15:29:58 +03:00

2.2 KiB
Raw Blame History

Agent with RAG Memory

This project implements a retrievalaugmented generation (RAG) agent that uses Qdrant as the vector store and Ollama for local LLM inference.
The agent follows the latest LangChain API and is fully configurable via environment variables.

Features

  • Qdrant vector store (via langchain-qdrant)
  • Ollama local LLM integration (via langchain-ollama)
  • Retrievalaugmented generation with conversation memory
  • Simple CLI interface for quick testing

Installation

# 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
pip install -r requirements.txt

Configuration

Create a .env file in the project root (or set environment variables directly):

# Qdrant
QDRANT_HOST=localhost
QDRANT_PORT=6333
QDRANT_API_KEY=  # leave empty if no key

# Ollama
OLLAMA_HOST=localhost
OLLAMA_PORT=11434
OLLAMA_MODEL=llama3

# Optional: collection name
QDRANT_COLLECTION=documents

Note

: The Qdrant instance must be running and accessible at the specified host/port.
The Ollama server must be running locally and expose the chosen model.

Usage

Adding Documents

from src.agent import Agent
from langchain_core.documents import Document

agent = Agent()

docs = [
    Document(page_content="Python is a programming language.", metadata={"source": "python.txt"}),
    Document(page_content="LangChain is a framework for LLM applications.", metadata={"source": "langchain.txt"}),
]

agent.add_documents(docs)

Querying the Agent

python -m src.agent "What is LangChain?"

or from Python:

response = agent.run("What is LangChain?")
print(response["answer"])

The response will include the answer and the source documents used.

Project Structure

agent-s-rag-pamyatyu/
├── src/
│   ├── agent.py
│   ├── config.py
│   └── vector_store.py
├── requirements.txt
├── pyproject.toml
└── README.md

License

MIT License