From e8d12abe75e1574bbbac92a5f282bf05e748ca66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Thu, 4 Jun 2026 22:56:48 +0000 Subject: [PATCH] Update README.md --- README.md | 92 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index f64ac73..98a8071 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,84 @@ -# RAG Agent with Qdrant and Ollama +# RAG‑Agent with Qdrant & Ollama -This repository contains a minimal but fully‑functional example of an AI agent that uses **Qdrant** as a local vector store, **Ollama** for embeddings and a local LLM, and **LangChain** for the agent logic. +This repository contains a minimal but functional implementation of a **RAG (Retrieval‑Augmented Generation) agent** that: -## Features +* Stores embeddings in a **Qdrant** vector database. +* Generates embeddings with **Ollama** (`nomic-embed-text`). +* Uses **LangChain** (v1+) for the agent, tools and prompt‑engineering. -* **Semantic search** – `search_knowledge_base` tool queries the vector store. -* **Document ingestion** – `add_to_knowledge_base` tool splits text into chunks and stores them. -* **Interactive CLI** – simple command line interface for adding documents, searching and chatting with the agent. -* **Modular design** – vector store, tools and agent logic are separated into distinct modules. +The agent can: -## Setup +* Search the knowledge base (`/search`). +* Add new documents (`/add`). +* Interact through a simple CLI. + +## Installation ```bash -# 1. Install Ollama models +# 1. Pull required Ollama models ollama pull llama3 ollama pull nomic-embed-text # 2. Install Python dependencies pip install -r requirements.txt -# 3. Start Qdrant (Docker recommended) -# docker run -p 6333:6333 qdrant/qdrant +# 3. Run the CLI +python -m src.cli +``` + +> **Note**: Qdrant must be running locally on port 6333. You can start it using Docker: +> +> ```bash +> 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 + ```bash -python -m workspace.task-6a02e23da6fe2e4ac16acf65.cli +python -m src.loader /path/to/text/files ``` -The CLI accepts the following commands: - -* `/add ` – add a new document. After the title you will be prompted to paste the content; finish with a line containing only `END`. -* `/search <query>` – perform a semantic search. -* `/quit` – exit. - -Anything else is forwarded to the agent. - -## Project structure +### Start the interactive CLI +```bash +python -m src.cli ``` -workspace/ -├── task-6a02e23da6fe2e4ac16acf65/ -│ ├── agent.py # Agent and tool definitions -│ ├── cli.py # Interactive command line interface -│ ├── vector_store.py # Qdrant + Ollama wrapper -│ ├── requirements.txt -│ └── README.md -``` \ No newline at end of file + +- `/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! \ No newline at end of file