MaximeRivest/attachments
Easiest way to give context to LLMs; Attachments has the ambition to be the general funnel for any files to be transformed into images+text for large language models context by only adding 2 lines to your python code.
What it solves
attachments is a library designed to convert various file formats (PDFs, Excel, Word, PowerPoint, HTML, images, audio, and even entire GitHub repositories) into a standardized, LLM-ready format. It eliminates the need for separate parsing libraries for each file type, providing a single function (att()) and a consistent output shape that can be inserted directly into prompts for multimodal LLMs like Claude or OpenAI.
How it works
The library uses a system of processors to handle different file types. Users can install optional dependencies for specific formats (e.g., pip install "attachments[pdf]") or use a service-based fallback mode.
Key features include:
- Universal Output: Every input is converted into a list of "Artifacts" (dictionaries containing text, images, and metadata).
- DSL Syntax: Options can be specified inline using a domain-specific language (e.g.,
att("report.pdf[pages: 1-4]")). - Multimodal Interleaving: By default, it interleaves text and images page-by-page, ensuring the model can associate visual content with the corresponding text.
- Token Estimation: It provides rough budget figures for text and images based on Claude's tokenization logic.
- Folder/Repo Handling: It can process entire directories or GitHub repositories, automatically filtering out secrets and dependency folders based on
.gitignorerules.
Who it’s for
Developers building LLM applications, RAG pipelines, or AI agents that need to to process a wide variety of unstructured data sources without writing custom parsing logic for every file format.
Highlights
- Single Entry Point: One function (
att()) handles everything from single files to URLs and GitHub repos. - ** uma Standardized Interface**: Consistent output shape (Artifacts) across all processors.
- Extensible Format Support: Support for PDF, XLSX, DOCX, PPTX, HTML, screenshots, OCR, and audio transcription.
- LLM-Specific Helpers: Built-in methods for formatting output specifically for Claude and OpenAI messages.
- Smart Filtering: Automatic exclusion of secrets and generated files when processing folders.
Related
- Project
- Project
- Project
- Project