Attachments: The Python Funnel for LLM Context and Multimodal Data

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Attachments: The Python Funnel for LLM Context and Multimodal Data

Summary

Attachments simplifies providing context to Large Language Models by transforming various file types into model-ready text and images. This Python library acts as a universal funnel, enabling developers to integrate diverse data sources like PDFs, images, web content, and even entire code repositories with just a few lines of code. It supports popular LLM APIs and frameworks, making multimodal AI development more accessible.

Repository Information

Analyzed by OSRepos on November 24, 2025

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

attachments is a powerful Python library designed to simplify providing context to Large Language Models (LLMs). It acts as a universal funnel, transforming various file types, including PDFs, images, web pages, and even entire code repositories, into model-ready text and base64 encoded images. With attachments, developers can integrate diverse data sources into their LLM applications with just a few lines of code, streamlining multimodal AI development.

Installation

Getting started with attachments is straightforward. You can install it using pip:

pip install attachments

For advanced features like CSS selector highlighting or Microsoft Office support, specific extras can be installed:

# For CSS selector highlighting (requires Playwright)
pip install attachments[browser]
playwright install chromium

# For Microsoft Office format support
pip install attachments[office]

Examples

attachments offers a simple API for common use cases and a powerful Domain Specific Language (DSL) for advanced processing.

Quick Start

Transform any file into LLM-ready content:

from attachments import Attachments

# Process a local file or a URL
ctx = Attachments("path/to/file.pdf") 
# or 
ctx = Attachments("https://example.com/document.docx")

llm_ready_text   = str(ctx)       # All extracted text, "prompt-engineered"
llm_ready_images = ctx.images     # list[str] – base64 PNGs

print(f"Extracted text length: {len(llm_ready_text)}")
print(f"Number of images: {len(llm_ready_images)}")

LLM Integration

attachments provides direct integration with popular LLM APIs like OpenAI and Anthropic, formatting the content appropriately:

from openai import OpenAI
from attachments import Attachments

# Process a PowerPoint presentation, selecting slides 3 to 5
pptx = Attachments("https://github.com/MaximeRivest/attachments/raw/main/src/attachments/data/sample_multipage.pptx[3-5]")

client = OpenAI()
resp = client.chat.completions.create(
    model="gpt-4.1-nano", # Use an appropriate vision-capable model
    messages=pptx.openai_chat("Analyze the following document:")
)
print(resp.choices[0].message.content)

Advanced DSL Usage

The DSL allows for precise control over content extraction and transformation:

  • Select pages or slides: report.pdf[1,3-5,-1]
  • Web content selection: url[select:title]
  • Image transformations: photo.jpg[rotate:90][crop:100,100,400,300]
  • Repository analysis: ./my-project[ignore:standard][max_files:100]

Why Use Attachments?

attachments stands out for several key reasons:

  • Comprehensive Multimodal Support: It handles a wide array of formats out of the box, including PDFs, PowerPoint, Word, Excel, CSV, TXT, Markdown, HTML, various image types, ZIP archives, and even Git repositories.
  • Simplified LLM Context: It abstracts away the complexity of parsing and formatting diverse data for LLMs, providing a unified text and images output.
  • Powerful DSL: The intuitive Domain Specific Language allows for granular control over content extraction, filtering, and transformation, enabling complex workflows with concise syntax.
  • Extensibility: The modular pipeline architecture allows users to easily extend its capabilities by adding custom loaders, modifiers, presenters, refiners, and adapters.
  • Direct LLM API Integration: It provides helper methods to format content directly for OpenAI, Anthropic, and DSPy, saving development time.
  • Advanced Features: Capabilities like CSS selector highlighting for web scraping and dedicated Microsoft Office support enhance its utility for specialized tasks.

Links

Explore the attachments project further on GitHub:

Related repositories

Similar repositories that may be relevant next.

Benchmark Radar: A Living Database for AI Benchmarks and Evaluation

Benchmark Radar: A Living Database for AI Benchmarks and Evaluation

September 29, 2026

Benchmark Radar is an extensive open-source project that tracks over 20,710 AI benchmark, evaluation, dataset, and data-quality records from 37 public sources. It provides daily updates, linked evidence, and tools for researchers and developers to discover and analyze AI benchmarks. This project is essential for anyone needing to stay current with AI evaluation trends and model performance.

AI BenchmarkLLM EvaluationAgentic Benchmarking
Pydantic AI Harness: Enhancing Your AI Agents with Robust Capabilities

Pydantic AI Harness: Enhancing Your AI Agents with Robust Capabilities

September 28, 2026

Pydantic AI Harness is the official capability and harness library for Pydantic AI, designed to extend agents for complex, long-running tasks. It provides a modular system of "capabilities" for functionalities like file system interaction, web research, memory, and sub-agent delegation. This library enables developers to build sophisticated and durable AI agents with ease.

PythonAIAgents
Bernstein: Open-Source Governance and Orchestration for AI Agents

Bernstein: Open-Source Governance and Orchestration for AI Agents

September 28, 2026

Bernstein is an open-source framework designed for the governance and orchestration of AI agents, allowing users to define rules declaratively. It enforces these policies and generates verifiable, replayable records of all agent activities. This Python-based solution provides a robust layer for managing complex AI agent workflows with transparency and accountability.

AI AgentsAgent GovernanceAI Orchestration
Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

Meshtastic-MCP: AI Tooling for Meshtastic Device Control and Testing

September 27, 2026

Meshtastic-MCP provides an MCP server and agent skills designed for AI tooling to discover, drive, observe, and test Meshtastic devices and applications. It offers a comprehensive suite of capabilities, from portable device control to advanced hardware-free end-to-end testing and replay functionalities. This project aims to streamline the development and testing of Meshtastic ecosystems.

PythonMeshtasticAI

Source repository

Open the original repository on GitHub.

21 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️