Skip to content

About

Autonomous AI agent for multi-document analysis with LangGraph, tool calling, and multi-step reasoning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🤖 Agentic Document Analyst

An autonomous AI agent that plans, reasons, and analyzes documents using multi-step tool calling. Upload invoices, contracts, or reports. Give it a task. Watch it think.

Not a chatbot. Not a search engine. An agent that autonomously decides which tools to use, processes multiple documents, reasons about the results, and delivers a structured analysis.

Python LangGraph LangChain Docker License


How it works

You say: "Compare pricing across all invoices and flag anything unusual."

The agent autonomously:

  1. Plans — decides it needs to read all documents, extract amounts, then compare
  2. Reads each document using OCR (calls read_document tool 3 times)
  3. Extracts structured data from each (calls extract_structured_data 3 times)
  4. Compares amounts across documents (calls compare_documents)
  5. Reasons about the results and identifies discrepancies
  6. Delivers a structured report with findings and recommendations

One instruction in. Complete analysis out. You can see every step the agent took.


Architecture

User gives task
      │
      ▼
┌─────────────────────────────────────────┐
│           LangGraph Agent               │
│                                         │
│  Plan → Pick Tool → Execute → Reason    │
│       ↑                    │            │
│       └────────────────────┘            │
│            (loops until done)           │
│                                         │
│  Available Tools:                       │
│  ┌─────────────┐  ┌──────────────────┐  │
│  │ read_document│  │ extract_data    │  │
│  └─────────────┘  └──────────────────┘  │
│  ┌─────────────┐  ┌──────────────────┐  │
│  │ search_docs │  │ compare_docs     │  │
│  └─────────────┘  └──────────────────┘  │
│  ┌─────────────┐                        │
│  │ list_docs   │                        │
│  └─────────────┘                        │
└─────────────────────────────────────────┘
      │
      ▼
Structured Report

Tech Stack

Layer Technology Why
Agent LangGraph State machine for multi-step reasoning with tool loops
LLM Groq (Llama 3.1 8B) Free API, fast inference
Tools LangChain Tools 5 custom tools the agent can call
Embeddings sentence-transformers Local, free, no API key
Vector Search FAISS Semantic search across documents
OCR Tesseract + pdfplumber Scanned and native PDF support
Backend FastAPI Async REST API
Frontend Streamlit Real-time agent thinking UI
Infra Docker One-command deployment

The 5 Agent Tools

Tool What it does
list_uploaded_documents Shows all available documents with IDs
read_document Reads full text of a specific document
extract_structured_data Extracts dates, amounts, emails, IBANs, references
search_across_documents Semantic search across all documents
compare_documents Compares a specific field across all documents

The agent decides which tools to use and in what order based on your task. It can call the same tool multiple times and loop between thinking and acting.


Quick Start

Prerequisites

Setup

git clone https://github.com/GouravJr/agentic-doc-analyst.git
cd agentic-doc-analyst

python -m venv venv
# Windows: venv\Scripts\activate
# Mac/Linux: source venv/bin/activate

pip install -r requirements.txt

copy .env.example .env
# Edit .env → add your GROQ_API_KEY

Run

Terminal 1 (backend):

uvicorn agent.main:app --reload

Terminal 2 (frontend):

streamlit run streamlit_app/app.py

Open http://localhost:8501


Project Structure

agentic-doc-analyst/
├── agent/
│   ├── config.py        # Configuration
│   ├── main.py          # FastAPI backend
│   └── graph.py         # LangGraph agent (the brain)
├── tools/
│   ├── document_store.py # Shared document storage
│   └── agent_tools.py    # 5 tools the agent uses
├── streamlit_app/
│   └── app.py           # Frontend with agent thinking UI
├── tests/
│   └── test_tools.py
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── README.md

What makes this different from a RAG chatbot

Feature RAG Chatbot This Agent
User interaction Ask a question, get an answer Give a task, get a full analysis
Steps 1 (retrieve + answer) 5-15 (plan + multi-tool execution)
Tool use None (just search) 5 tools, agent picks which to use
Multi-document Search across docs Read, extract, compare across docs
Reasoning None Plans approach, reasons about results
Transparency Shows sources Shows every reasoning step

Example Tasks

  • "Summarize all uploaded documents and highlight key differences"
  • "Extract all financial data and compare amounts across invoices"
  • "Find any discrepancies in dates, amounts, or references"
  • "Search for payment terms and compare across all contracts"
  • "List all contacts, emails, and phone numbers found in the documents"

Author

Gourav Srinivasalu M.Sc. Artificial Intelligence Engineering, Universitat Passau


License

MIT License

About

Autonomous AI agent for multi-document analysis with LangGraph, tool calling, and multi-step reasoning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages