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.
You say: "Compare pricing across all invoices and flag anything unusual."
The agent autonomously:
- Plans — decides it needs to read all documents, extract amounts, then compare
- Reads each document using OCR (calls
read_documenttool 3 times) - Extracts structured data from each (calls
extract_structured_data3 times) - Compares amounts across documents (calls
compare_documents) - Reasons about the results and identifies discrepancies
- Delivers a structured report with findings and recommendations
One instruction in. Complete analysis out. You can see every step the agent took.
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
| 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 |
| 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.
- Python 3.12
- Tesseract OCR installed
- Free Groq API key from console.groq.com
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_KEYTerminal 1 (backend):
uvicorn agent.main:app --reloadTerminal 2 (frontend):
streamlit run streamlit_app/app.pyagentic-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
| 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 |
- "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"
Gourav Srinivasalu M.Sc. Artificial Intelligence Engineering, Universitat Passau
- GitHub: github.com/GouravJr
- LinkedIn: linkedin.com/in/gourav-srinivasalu
- Email: gourav.srinivasalu@gmail.com
MIT License