Metadata-Version: 2.4
Name: agentic-rag-pdf
Version: 0.1.3
Summary: Agentic RAG over any PDF — grounded, cited answers from research reports, ESG/sustainability disclosures, contracts, manuals, and filings. Multi-agent LangGraph workflow with hybrid retrieval, RAPTOR summaries, NL→SQL over extracted tables, CRAG corrective loops, and a defense-in-depth hallucination stack.
Author-email: Bhagat Kumar Das <bhagatkumar75@gmail.com>
Maintainer-email: Bhagat Kumar Das <bhagatkumar75@gmail.com>
License: Proprietary
Project-URL: Homepage, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF
Project-URL: Repository, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF
Project-URL: Issues, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF/issues
Project-URL: Documentation, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF#readme
Project-URL: Release Notes, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF/releases
Project-URL: Source Code, https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF
Keywords: rag,agentic-rag,retrieval-augmented-generation,langgraph,langchain,ollama,faiss,bm25,hybrid-search,raptor,crag,rerank,cross-encoder,pdf,pdf-extraction,table-extraction,ocr,llm,ai-agent,multi-agent,chatbot,question-answering,vector-search,embedding,fastapi,sustainability,esg,hallucination-detection,citation,faithfulness
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: FastAPI
Classifier: Environment :: Web Environment
Classifier: Environment :: Console
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Text Processing :: Indexing
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: langgraph>=0.4.0
Requires-Dist: langchain>=0.3.0
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: langchain-ollama>=0.3.0
Requires-Dist: langchain-community>=0.3.0
Requires-Dist: langsmith>=0.2.0
Requires-Dist: faiss-cpu>=1.8.0
Requires-Dist: rank-bm25>=0.2.2
Requires-Dist: sentence-transformers>=3.0.0
Requires-Dist: PyMuPDF>=1.24.0
Requires-Dist: pymupdf4llm>=0.0.10
Requires-Dist: easyocr>=1.7.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: fastapi>=0.110.0
Requires-Dist: uvicorn[standard]>=0.30.0
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: sse-starlette>=2.0.0
Requires-Dist: ragas>=0.2.0
Requires-Dist: datasets>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: Pillow>=10.0.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: scikit-learn>=1.4.0

# PdfAgent — Agentic RAG over any PDF

> Grounded answers from your PDFs, with source citations.

[![PyPI](https://img.shields.io/pypi/v/agentic-rag-pdf.svg)](https://pypi.org/project/agentic-rag-pdf/)
[![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)
[![LangGraph](https://img.shields.io/badge/LangGraph-1.0+-1c3d5a.svg)](https://langchain-ai.github.io/langgraph/)
[![FAISS](https://img.shields.io/badge/FAISS-1.8+-4b3f72.svg)](https://github.com/facebookresearch/faiss)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.110+-009688.svg)](https://fastapi.tiangolo.com/)
[![Ollama](https://img.shields.io/badge/Ollama-local%20LLM-000000.svg)](https://ollama.com/)
[![License](https://img.shields.io/badge/license-Proprietary-lightgrey.svg)](#license)

Ask questions about any PDF — research reports, contracts, manuals, ESG / sustainability filings — and get **grounded, cited answers**. Drop a PDF into the browser UI and start asking.

![PdfAgent UI](https://raw.githubusercontent.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF/master/docs/ui-screenshot.png)

---

## Quick Start

```bash
# 1. Install
pip install agentic-rag-pdf

# 2. Install + start Ollama (https://ollama.com/download), pull the embedding model
ollama pull mxbai-embed-large
ollama signin                       # only if using cloud models (e.g. gpt-oss:120b-cloud)

# 3. Launch the UI
pdfagent
```

Open **http://localhost:8000** → click **Upload PDF** → drop a file → ask questions.

> The PyPI distribution name is `agentic-rag-pdf` (the bare `pdfagent` name is owned by an unrelated project). The console command is `pdfagent`.

---

## What it does

- **Multi-modal ingestion** — text, tables (extracted into SQLite), images (OCR + optional vision captions).
- **Hybrid retrieval** — BM25 + FAISS dense, merged with Reciprocal Rank Fusion, with optional cross-encoder reranking.
- **RAPTOR** hierarchical summaries for global queries; **Map-Reduce** for exhaustive aggregation.
- **Schema-aware NL → SQL** for tabular queries (SELECT-only, sandboxed).
- **Hallucination defense (CRAG + 7 layers)** — pre-synthesis entity-metric fact extraction, deterministic attribution check, citation verification, claim-level faithfulness, cross-chunk contradiction detection, arithmetic verification of delta tables.
- **Three interfaces** — browser UI (SSE-streamed agent steps), REST API, CLI.

See **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** for the workflow diagram, full feature breakdown, configuration reference, REST API, and project structure.

---

## Other ways to install

**From the latest GitHub commit** (handy between releases):

```bash
pip install git+https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF.git
```

**For development** (editable, clone the repo):

```bash
git clone https://github.com/bhagatdas/PdfAgent-Agentic-RAG-over-any-PDF.git
cd PdfAgent-Agentic-RAG-over-any-PDF
pip install -e .
pdfagent --reload
```

---

## Command-line usage

The wheel installs two console scripts:

```bash
pdfagent                              # launch the browser UI (uvicorn on :8000)
pdfagent --host 0.0.0.0 --port 8080   # custom bind

pdfagent-cli ingest                   # CLI ingest (drop files in data/pdfs/ first)
pdfagent-cli query "..."              # one-shot question
pdfagent-cli chat                     # interactive REPL
pdfagent-cli schema                   # print the table schema catalog
```

Override defaults via a `.env` file in your working directory. The full settings reference lives in [config/settings.py](config/settings.py).

---

## REST API at a glance

| Method | Path | Purpose |
|:------:|:-----|:--------|
| `POST` | `/query` | Run the pipeline; JSON response |
| `POST` | `/query/stream` | Same, streamed via SSE (one event per agent) |
| `POST` | `/upload-ingest/stream` | Wipe + ingest a single PDF |
| `GET`  | `/health` | Vector store doc count + table count |
| `GET`  | `/ollama/health` | Probe Ollama readiness + per-OS install help |

Full endpoint table and request/response shape: [docs/ARCHITECTURE.md#rest-api](docs/ARCHITECTURE.md#rest-api).

---

## Tech stack

**LangGraph** + LangChain · **Ollama** (gpt-oss:120b-cloud, mxbai-embed-large) · **FAISS** + rank-bm25 · cross-encoder reranker · **SQLite** for tables · **FastAPI** (SSE) · PyMuPDF · EasyOCR.

---

## Publishing

Releases go to PyPI as `agentic-rag-pdf` on every `v*` tag push. See [PUBLISHING.md](PUBLISHING.md) for the one-time trusted-publisher setup and the tag → release flow.

---

## License

Proprietary — see repository owner.

---

*Built by [Bhagat Kumar Das](https://github.com/bhagatdas).*
