2026-06-04 22:57:36 +00:00
2026-06-04 22:57:36 +00:00
2026-06-04 20:03:19 +00:00
2026-06-04 20:02:14 +00:00
2026-06-03 08:44:03 +00:00
2026-06-04 20:02:26 +00:00
2026-06-04 20:02:32 +00:00
2026-06-04 20:02:38 +00:00
2026-06-04 20:02:44 +00:00
2026-06-04 20:02:50 +00:00
2026-06-04 22:56:48 +00:00
2026-06-04 22:56:54 +00:00
2026-06-04 20:03:08 +00:00
2026-06-04 20:03:14 +00:00

RAGAgent with Qdrant & Ollama

This repository contains a minimal but functional implementation of a RAG (RetrievalAugmented Generation) agent that:

  • Stores embeddings in a Qdrant vector database.
  • Generates embeddings with Ollama (nomic-embed-text).
  • Uses LangChain (v1+) for the agent, tools and promptengineering.

The agent can:

  • Search the knowledge base (/search).
  • Add new documents (/add).
  • Interact through a simple CLI.

Installation

# 1. Pull required Ollama models
ollama pull llama3
ollama pull nomic-embed-text

# 2. Install Python dependencies
pip install -r requirements.txt

# 3. Run the CLI
python -m src.cli

Note

: Qdrant must be running locally on port 6333. You can start it using Docker:

docker run -p 6333:6333 qdrant/qdrant

Directory structure

workspace/task-6a02e23da6fe2e4ac16acf65/
├─ src/
│  ├─ vector_store.py   # Qdrant wrapper
│  ├─ tools.py          # LangChain tools
│  ├─ agent.py          # Agent implementation
│  ├─ loader.py         # Utility for bulk loading
│  └─ cli.py            # Interactive CLI
├─ requirements.txt
└─ README.md

Usage

Load documents from a folder

python -m src.loader /path/to/text/files

Start the interactive CLI

python -m src.cli
  • /add add a new document.
  • /search perform a semantic search.
  • /quit exit.

Any other input is treated as a user message and processed by the agent.

How it works

  1. Vector store KnowledgeBase wraps QdrantVectorStore. It splits documents into chunks using RecursiveCharacterTextSplitter, embeds them with OllamaEmbeddings, and stores the vectors.
  2. Tools Two tools (search_knowledge_base, add_to_knowledge_base) are exposed to the agent via LangChain's @tool decorator.
  3. Agent Built with create_tool_calling_agent and AgentExecutor. The system prompt encourages the assistant to use the tools.
  4. CLI Provides a simple REPL for adding documents, searching, and chatting with the agent.

Extending

  • Replace the embedding model with any Ollama model.
  • Swap Qdrant for another vector store supported by LangChain.
  • Add more tools (e.g., delete, update) following the same pattern.

Happy experimenting!

S
Description
Агент с RAG-памятью
Readme 275 KiB
Languages
Python 100%