Update README.md

This commit is contained in:
2026-06-01 17:40:41 +00:00
parent 3d0e1c3713
commit 27c8d2294f
+65 -2
View File
@@ -1,3 +1,66 @@
# task-6a1864f78a94f887e50d46da
# RAG Agent with ChromaDB and Tavily
Экзамен: RAG-агент с ChromaDB и веб-поиском
## Overview
This repository implements a **RAG (RetrievalAugmented Generation) agent** that can answer questions by searching a local knowledge base stored in **ChromaDB** or by fetching uptodate 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 realtime web queries.
- **Automatic Routing** The agent decides whether to use the local KB or the web search.
- **CLI** Simple commandline 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 **ZeroShot 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 reindex.
- Ensure the Ollama server is running locally when executing the agent.