Update README.md

This commit is contained in:
2026-06-04 20:08:36 +00:00
parent 3ddfb6392a
commit 7abe0ab34b
+57 -57
View File
@@ -1,79 +1,79 @@
# RAG Agent with ChromaDB and Tavily # RAG Agent with Qdrant and Tavily
This repository contains a lightweight RAG (RetrievalAugmented Generation) agent that: This repository implements an AI agent that can answer questions using a local knowledge base stored in **Qdrant** and uptodate information fetched from the web via **Tavily**. The agent is built with **LangChain 1.x** and **Ollama** for local LLM and embeddings.
1. Stores local knowledge in **ChromaDB** using **Ollama** embeddings. ## Features
2. Performs semantic search over the local store.
3. Falls back to **Tavily** web search for uptodate information.
4. Decides automatically which source to use and indicates the source in the answer.
## Prerequisites * **Local RAG** Semantic search in Qdrant using Ollama embeddings.
* **Web search** Tavily integration for realtime information.
* Python 3.10+ (recommended via `pyenv` or `conda`). * **Automatic source selection** The LLM decides whether to use the local KB or the web.
* [Ollama](https://ollama.ai/) installed locally. * **Persistent vector store** Data is saved in `./qdrant_db` and reused across runs.
* A Tavily API key set it in a `.env` file. * **Interactive CLI** Add documents, ask questions, and see the source.
```bash
# Pull the required models
ollama pull llama3
ollama pull nomic-embed-text
```
## Installation ## Installation
```bash ```bash
# 1. Pull required Ollama models
ollama pull llama3
ollama pull nomic-embed-text
# 2. Install Python dependencies
pip install -r requirements.txt 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 ## Usage
```bash ```bash
# Create a .env file with your Tavily key # Start the CLI
# TAVILY_API_KEY=YOUR_KEY python -m workspace.task-6a1864f78a94f887e50d46da.cli
# Populate the vector store from the documents folder
python main.py
``` ```
You will be presented with a prompt. Type your question and press **Enter**. Commands:
Type `exit` to quit.
* `/add <directory>` Load all `.txt` and `.md` files from the directory into Qdrant.
* `/search <question>` 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 ## Project Structure
``` ```
├── agent.py # Agent definition workspace/
├── main.py # CLI entry point ├─ task-6a1864f78a94f887e50d46da/
├── tools.py # Local KB and web search tools │ ├─ vector_store.py # Qdrant vector store helpers
├── vectorstore.py # ChromaDB helpers │ ├─ tools.py # Local KB and web search tools
├── requirements.txt │ ├─ agent.py # Agent definition
├── README.md │ ├─ cli.py # Interactive command line
└── documents/ # Folder with .txt/.md files to ingest │ ├─ requirements.txt
│ └─ README.md
``` ```
## How It Works ## License
1. **Vector Store** `vectorstore.py` creates a ChromaDB instance backed by MIT
`OllamaEmbeddings`. Documents from `documents/` are chunked with
`RecursiveCharacterTextSplitter` and added to the store.
2. **Tools** `tools.py` exposes two LangChain tools:
* `search_local_kb` semantic search in ChromaDB.
* `web_search` web search via Tavily.
3. **Agent** `agent.py` builds an OpenAIfunctionsstyle agent that
chooses between the two tools based on the users query. The system prompt
instructs the LLM to use `search_local_kb` for knowledgebase queries and
`web_search` for recent facts. The answer always contains a source tag.
4. **CLI** `main.py` ties everything together: it loads the vector store,
creates the agent and runs an interactive chat loop.
## Extending
* Replace the LLM with any other LangChaincompatible model.
* Add more tools (e.g., database queries, file system access).
* Persist the vector store across runs it already does this via `persist_directory`.
---
Happy experimenting!