From 27c8d2294f17bfe9932e4734666d8a0237776633 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: Mon, 1 Jun 2026 17:40:41 +0000 Subject: [PATCH] Update README.md --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73e3e73..7d7bdd1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,66 @@ -# task-6a1864f78a94f887e50d46da +# RAG Agent with ChromaDB and Tavily -Экзамен: RAG-агент с ChromaDB и веб-поиском \ No newline at end of file +## Overview + +This repository implements a **RAG (Retrieval‑Augmented Generation) agent** that can answer questions by searching a local knowledge base stored in **ChromaDB** or by fetching up‑to‑date information from the web using **Tavily**. The agent automatically chooses the most appropriate source based on the query and returns the answer together with the source identifier. + +## Features + +- **Local Knowledge Base** – Vector store backed by ChromaDB with embeddings from Ollama (`nomic-embed-text`). +- **Web Search** – Uses Tavily API for real‑time web queries. +- **Automatic Routing** – The agent decides whether to use the local KB or the web search. +- **CLI** – Simple command‑line interface for interactive queries. +- **Persistence** – The ChromaDB store is persisted between runs. + +## Setup + +1. **Install Ollama** and pull the required models: + ```bash + ollama pull llama3 + ollama pull nomic-embed-text + ``` + +2. **Install Python dependencies**: + ```bash + pip install -r requirements.txt + ``` + +3. **Set up the Tavily API key**. Create a `.env` file in the project root with: + ```env + TAVILY_API_KEY=your_api_key_here + ``` + +4. **Add documents** you want to index into the `documents/` folder. The script will automatically load `.txt` and `.md` files. + +## Usage + +```bash +python main.py +``` + +You will be prompted for a query. Type `exit` to quit. + +Example: +``` +Query: Какие последние новости про AI-агентов? +Answer: +[Web Search] +1. AI Agents are ... + https://example.com + ... +Source: tavily +``` + +## Project Structure + +- `vectorstore.py` – Helper functions for creating and populating the ChromaDB vector store. +- `agent.py` – Defines the tools and initializes the LangChain agent. +- `main.py` – CLI entry point. +- `requirements.txt` – Python dependencies. +- `README.md` – Documentation. + +## Notes + +- The agent uses the **Zero‑Shot React** strategy. It may call both tools if the query is ambiguous. You can tweak the prompt or the routing logic if needed. +- The ChromaDB store is persisted in `./chroma_db`. Delete this folder to re‑index. +- Ensure the Ollama server is running locally when executing the agent. \ No newline at end of file