Skip to main content

Unified document interrogation: retrieve, screenshot, search

Project description

docrouter

A swiss army knife for document handling in LLM agents and apps.

docrouter provides a unified API to extract text, search content, and render pages across multiple document formats. It's designed for rapid prototyping - when you need to quickly build an agent that can work with PDFs, Word docs, PowerPoints, and more without wrestling with a dozen different libraries.

What this is

  • A single interface for text extraction and search across PDF, DOCX, PPTX, HTML, Markdown, and plain text
  • Built with LLM tool-calling in mind (includes a ready-to-use tool API with document registry)
  • Zero core dependencies - install only what you need
  • Good enough extraction for most prototyping and simple production use cases

What this isn't

This library doesn't compete with state-of-the-art (often paid, API-based) solutions for individual file types. If you need production-grade PDF extraction with perfect table parsing, OCR, or layout analysis, check out specialized tools like Datalab - they're excellent at what they do.

docrouter is for when you need to get something working quickly across multiple formats without overthinking it.

Installation

pip install docrouter[all]  # all formats
pip install docrouter[pdf]  # PDF only
pip install docrouter       # txt/md only (no deps)

Optional dependencies by format:

  • pdf - PyMuPDF
  • docx - python-docx
  • pptx - python-pptx
  • html - BeautifulSoup4, lxml

Quick start

from docrouter import open_document

doc = open_document("report.pdf")
doc.info()              # metadata: pages, title, etc.
doc.get_text()          # full document text
doc.search("revenue")   # find text with context
doc.render_page(0)      # screenshot page as PNG (PDF only)

Tool API (for LLM agents)

The tool API maintains a document registry, making it easy to integrate with function-calling LLMs:

from docrouter.tools import (
    open_document_tool,
    search_tool,
    get_text_tool,
    close_document_tool
)

# Open and register a document
result = open_document_tool("quarterly_report.pdf")
doc_id = result["document_id"]

# Search across the document
hits = search_tool(doc_id, "operating income", max_hits=5)

# Get full text or specific pages
text = get_text_tool(doc_id)

# Clean up when done
close_document_tool(doc_id)

Supported formats

Format Extensions Unit type Features
PDF .pdf page text, search, render
Word .docx section text, search, tables
PowerPoint .pptx slide text, search, tables, notes
HTML .html, .htm section text, search
Markdown .md chunk text, search
Plain text .txt, .csv, .json, etc. chunk text, search
Code .py, .js, .ts, etc. chunk text, search
Images .png, .jpg, etc. - metadata only

Contributing

Contributions are welcome! If you'd like to extend docrouter with new formats, better extraction for existing ones, or other improvements, please open an issue or PR.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docrouter-0.1.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docrouter-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file docrouter-0.1.0.tar.gz.

File metadata

  • Download URL: docrouter-0.1.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for docrouter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54d258987901b9c93fee298760e34946f1436a89b9816f9c5a154f8324c0fbdb
MD5 190b7fc267dbf3f11c67f32e687b3067
BLAKE2b-256 3027dd5abac83193da0ca118695f3dd7123ac1262297dd50e22f104f97db5bf4

See more details on using hashes here.

File details

Details for the file docrouter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: docrouter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for docrouter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86fb98596b9aae07299ddd1d8101f97bb91402ff4318fbb1ec174270c5dd4970
MD5 d4f29df11cb740bb5c8ba4bde5636496
BLAKE2b-256 eec90f2dc6ef6cc1090f4525c3d0a2f22e6abd3341326acf837195c16552db32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page