2026-06-02 07:12:38 +00:00
2026-06-01 17:36:32 +00:00
2026-06-02 07:10:50 +00:00
2026-06-01 17:36:32 +00:00
2026-06-01 17:40:35 +00:00
2026-06-02 07:11:01 +00:00
2026-06-02 07:11:07 +00:00
2026-06-02 07:11:12 +00:00
2026-06-02 07:11:17 +00:00

RAG Agent with ChromaDB and Web Search

This repository implements a simple RAG (RetrievalAugmented Generation) agent that can answer questions using a local knowledge base stored in ChromaDB and also perform realtime web search via Tavily. The agent automatically decides which source to use and reports the chosen source in the answer.

Features

  • Local knowledge base Text files (.txt, .md) are loaded, chunked, and stored in a persistent ChromaDB collection.
  • Semantic search Uses Ollama embeddings (nomic-embed-text).
  • Web search Powered by Tavily.
  • Automatic source selection The agent chooses between local and web search based on the query.
  • CLI Simple chat loop with exit to quit.

Setup

# 1. Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Pull required Ollama models
ollama pull llama3
ollama pull nomic-embed-text

# 4. Set your Tavily API key
export TAVILY_API_KEY=YOUR_KEY   # Windows: set TAVILY_API_KEY=YOUR_KEY

Usage

  1. Load documents Place your .txt or .md files in the documents/ folder.
  2. Run the agent
    python agent.py
    
  3. Chat Type your question. Type exit to quit.

Example

Query: Какие последние новости про AI-агентов?
[Web Search] ...
Источник: tavily

Query: Что в наших конспектах про LangGraph?
[Local KB] ...
Источник: chromadb

Project Structure

  • vectorstore.py Functions to create and load the ChromaDB vector store.
  • rag_tools.py Two LangChain tools: search_local_kb and web_search.
  • agent.py Main script that sets up the agent and runs the chat loop.
  • requirements.txt Python dependencies.
  • README.md This file.

License

MIT License.

S
Description
Экзамен: RAG-агент с ChromaDB и веб-поиском
Readme 192 KiB
Languages
Python 100%