Skip to content

Repository files navigation

Document Analysis Chatbot

A multi-agent RAG (Retrieval-Augmented Generation) system for analyzing documents using local LLMs.

Features

  • Multi-Agent Architecture - Specialized agents for different tasks:

    • Q&A Agent - Answer questions about documents
    • Summary Agent - Generate summaries (brief, detailed, executive, financial)
    • MCQ Agent - Create multiple choice quizzes
    • Orchestrator - Auto-routes queries to the appropriate agent
  • Interactive Quiz Mode - Practice with questions one at a time, get instant feedback and track your score

  • Dual Interface:

    • Web UI (Streamlit) - Upload files, chat, quick actions
    • CLI - Menu-driven terminal interface
  • 100% Local & Free - No API keys required, all processing runs locally

Technologies

Component Technology
LLM Ollama (llama3, mistral, phi3)
Embeddings HuggingFace sentence-transformers
Vector Store ChromaDB
Web UI Streamlit
Language Python 3.10+

Prerequisites

  1. Python 3.10+

  2. Ollama - Install from ollama.ai

   # macOS
   brew install ollama
   
   # Or download from https://ollama.ai/download
  1. Download an LLM model
   # Start Ollama service
   ollama serve
   
   # Pull a model (in another terminal)
   ollama pull llama3      # Recommended, 8B params
   # OR
   ollama pull mistral     # Good alternative
   # OR
   ollama pull phi3        # Smaller, faster

Installation

    # Create virtual environment
    python -m venv .venv
    source .venv/bin/activate  # Windows: .venv\Scripts\activate
    
    # Install dependencies
    pip install -r requirements.txt

Usage

Web App

    streamlit run app.py

Open http://localhost:8501 in your browser.

  1. Upload documents or load from data/pdfs/ and data/csvs/
  2. Chat with your documents
  3. Use quick action buttons or interactive quiz

CLI

    python cli.py

Menu options:

# Action
1 Load documents
2 Chat (auto-routing)
3 Q&A Agent
4 Summary Agent
5 MCQ Agent
6 Interactive Quiz
7 Free Prompt
8 Show stats
0 Exit

Python API

from vectorstore.store import VectorStore, load_documents_to_store
from agents.orchestrator import Orchestrator, QAAgent, SummaryAgent, MCQAgent

# Load documents
vector_store = load_documents_to_store()

# Chat
orchestrator = Orchestrator(vector_store=vector_store)
response = orchestrator.run("What are the key findings?")

# Direct Agent Access
# Q&A Agent
qa = QAAgent(vector_store=vector_store)
answer = qa.run("What are the main risks mentioned?")
answer_with_sources = qa.answer_with_citations("What is the revenue?")

# Summary Agent
summary_agent = SummaryAgent(vector_store=vector_store)
summary = summary_agent.run("financial report", summary_type="executive")
insights = summary_agent.extract_key_insights()

# MCQ Agent
mcq = MCQAgent(vector_store=vector_store)
questions = mcq.generate_mcqs("accounting principles", num_questions=10)
quiz = mcq.generate_quiz("finance basics", include_answers=False)
answer_key = mcq.generate_answer_key("finance basics")

Project Structure

├── app.py                  # Streamlit web UI
├── cli.py                  # Command line interface
├── config.py               # Configuration
├── agents/
│   ├── base_agent.py       # Base class with LLM calls
│   ├── orchestrator.py     # Query routing
│   ├── qa_agent.py         # Question answering
│   ├── summary_agent.py    # Summarization
│   └── mcq_agent.py        # Quiz generation
├── vectorstore/
│   └── store.py            # ChromaDB + embeddings
├── document_processing/
│   ├── pdf_loader.py       # PDF extraction
│   ├── csv_loader.py       # CSV/Excel loading
│   └── chunker.py          # Text chunking
└── data/
    ├── pdfs/               # Your PDF files
    └── csvs/               # Your CSV files

Screenshots

CLI Interface


Interactive Quiz


Summary Agent

About

A multi-agent RAG (Retrieval-Augmented Generation) system for analyzing documents using local LLMs.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages