From aa2aa8d71dea492ed67aae4c3be58cb3fb177fb6 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: Fri, 5 Jun 2026 11:21:08 +0000 Subject: [PATCH] Update README.md --- README.md | 141 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 5a05b0a..2114b81 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,86 @@ -# RAG Agent with Qdrant and Tavily +# RAG Agent with ChromaDB and Tavily Web Search -This repository implements an AI agent that can answer questions using a local knowledge base stored in **Qdrant** and up‑to‑date information fetched from the web via **Tavily**. The agent is built with **LangChain 1.x** and **Ollama** for local LLM and embeddings. +## Overview -## Features +This repository contains a simple RAG (Retrieval‑Augmented Generation) agent that can answer user questions by searching a local knowledge base stored in **ChromaDB** and by performing live web searches via **Tavily**. The agent automatically selects the appropriate source and reports it in the answer. -* **Local RAG** – Semantic search in Qdrant using Ollama embeddings. -* **Web search** – Tavily integration for real‑time information. -* **Automatic source selection** – The LLM decides whether to use the local KB or the web. -* **Persistent vector store** – Data is saved in `./qdrant_db` and reused across runs. -* **Interactive CLI** – Add documents, ask questions, and see the source. +The project uses the following stack: -## Installation +- **Python 3.10+** +- **LangChain 1.x** – modern agent framework +- **ChromaDB** – local vector store +- **Ollama** – LLM (`llama3`) and embeddings (`nomic-embed-text`) +- **Tavily** – web search API +- **LangGraph** – (not used directly, but required by LangChain 1.x) -```bash -# 1. Pull required Ollama models -ollama pull llama3 -ollama pull nomic-embed-text - -# 2. Install Python dependencies -pip install -r requirements.txt - -# 3. Run Qdrant (Docker recommended) -# If you prefer a local binary, download from https://qdrant.tech -# Docker command: -# docker run -p 6333:6333 qdrant/qdrant -``` - -## Usage - -```bash -# Start the CLI -python -m workspace.task-6a1864f78a94f887e50d46da.cli -``` - -Commands: - -* `/add ` – Load all `.txt` and `.md` files from the directory into Qdrant. -* `/search ` – Ask the agent a question. -* `/quit` – Exit. - -Example: - -``` -> /add ./documents -Loaded 12 chunks into Qdrant. -Documents added. -> /search What is LangGraph? -Answer: -LangGraph is a framework for building ... -Source: chromadb -``` - -## Environment Variables - -* `TAVILY_API_KEY` – Your Tavily API key. - -Create a `.env` file in the project root: - -``` -TAVILY_API_KEY=your_api_key_here -``` - -## Project Structure +## Folder structure ``` workspace/ -├─ task-6a1864f78a94f887e50d46da/ -│ ├─ vector_store.py # Qdrant vector store helpers -│ ├─ tools.py # Local KB and web search tools -│ ├─ agent.py # Agent definition -│ ├─ cli.py # Interactive command line -│ ├─ requirements.txt -│ └─ README.md +├─ documents/ # .txt/.md files that will be loaded into Chroma +├─ chroma_db/ # persistent Chroma data (created on first run) +├─ main.py # CLI entry point +├─ vectorstore.py # Chroma store helpers +├─ tools.py # Agent tools +├─ README.md +└─ requirements.txt ``` +## Setup + +1. **Install Ollama** and pull the required models: + ```bash + ollama pull llama3 + ollama pull nomic-embed-text + ``` + +2. **Set the Tavily API key** (obtain a free key from https://tavily.com): + ```bash + export TAVILY_API_KEY=your_api_key_here + ``` + On Windows use `set` instead of `export`. + +3. **Install Python dependencies**: + ```bash + pip install -r requirements.txt + ``` + +4. **Add documents** you want the agent to know about into the `documents/` folder. Any `.txt` or `.md` files will be automatically loaded. + +## Running the Agent + +```bash +python main.py +``` + +You will see a prompt where you can type questions. Type `exit`, `quit`, or `q` to end the session. + +Example interaction: + +``` +User: What are the latest developments in AI agents? +Assistant: [Web Search] - ... +Source: tavily + +User: What does our lab say about LangGraph? +Assistant: [Local KB] - ... +Source: chromadb +``` + +## How It Works + +1. **Vector Store** – `vectorstore.py` creates a persistent Chroma collection using `OllamaEmbeddings`. Documents from `documents/` are split with `RecursiveCharacterTextSplitter` and added to the store. +2. **Tools** – `tools.py` defines two tools: + * `search_local_kb` – semantic search in the local vector store. + * `web_search` – live web search via Tavily. +3. **Agent** – In `main.py` we create a `ChatOllama` LLM and pass the two tools to `create_agent`. A system prompt instructs the LLM to choose the correct tool. The agent returns the answer along with a source tag. + +## Extending + +- Add more documents to `documents/` and restart the CLI – the store will be updated automatically. +- Replace the LLM or embedding model by changing the `ChatOllama` and `OllamaEmbeddings` parameters. +- Add additional tools (e.g., file system access, calculator) following the same pattern. + ## License -MIT \ No newline at end of file +MIT License. \ No newline at end of file