2026-05-28 09:35:30 +00:00
2026-05-28 09:27:38 +00:00
2026-05-28 09:35:30 +00:00
2026-05-28 09:27:42 +00:00
2026-05-28 09:27:47 +00:00
2026-05-28 09:16:29 +00:00
2026-05-28 09:27:58 +00:00
2026-05-28 09:35:17 +00:00
2026-05-28 09:27:32 +00:00
2026-05-28 09:27:16 +00:00

RAG Agent with ChromaDB

Overview

This repository implements a simple RAG (RetrievalAugmented Generation) agent that uses ChromaDB as the vector store and Ollama for embeddings and LLM inference. The agent can:

  1. Add documents to the knowledge base.
  2. Search the knowledge base semantically.
  3. Interact via a lightweight CLI.

File Structure

  • requirements.txt Python dependencies.
  • chunker.py Text chunking utilities (RecursiveCharacterTextSplitter).
  • vector_store.py Wrapper around ChromaDB collection.
  • tools.py LangChain tools for search and add operations.
  • agent.py Agent creation with LangChain create_agent.
  • cli.py Simple commandline interface.
  • init_documents.py Helper to load all .txt files from a directory into the vector store.

Installation

# Pull Ollama models
ollama pull llama3
ollama pull nomic-embed-text

# Install Python packages
pip install -r requirements.txt

Usage

  1. Load documents (optional):
    python init_documents.py
    
  2. Run the CLI:
    python cli.py
    
    Type any question or /quit to exit.

Architecture

  • Chunking: chunker.split_text() splits large texts into 500char chunks with 100char overlap using LangChains RecursiveCharacterTextSplitter.
  • Vector Store: vector_store.ChromaVectorStore handles adding documents and similarity search. Embeddings are generated by langchain_ollama.OllamaEmbeddings (nomic-embed-text).
  • Tools: Two tools decorated with @tool: search_knowledge_base and add_to_knowledge_base. They interact with the vector store.
  • Agent: Created via LangChains create_agent, configured to use the two tools and a simple system prompt. The LLM is an Ollama llama3 instance.

Testing

Run the CLI and try:

/quit
Hello, what can you do?

The agent should respond using the knowledge base or add new documents if prompted.

S
Description
No description provided
Readme 93 KiB
Languages
Python 100%