Skip to content

0.2.11

Choose a tag to compare

@DEENUU1 DEENUU1 released this 07 Jun 17:31
· 10 commits to main since this release
9adfdea

[0.2.11] - 2026-06-07

Added

  • read_file can return PDFs as BinaryContent for document understanding (#48) (src/pydantic_ai_backends/toolsets/console.py). Previously create_console_toolset's read_file returned raster images (png/jpg/jpeg/gif/webp) as pydantic_ai.BinaryContent under image_support, but PDFs fell through to the text path and were read via the awk-based BaseSandbox.read, which on a binary PDF emits an empty string — so read_file("report.pdf") returned "" instead of usable content. Documents are now handled as a separate, independent content kind from images:
    • New document_support: bool = False and max_document_bytes parameters on create_console_toolset (default off → fully backward compatible; image_support / max_image_bytes unchanged).
    • New exported constants, kept disjoint from the image ones: DOCUMENT_EXTENSIONS ({"pdf"}), DOCUMENT_MEDIA_TYPES ({"pdf": "application/pdf"}), and DEFAULT_MAX_DOCUMENT_BYTES (50 MB). When document_support=True, reading a PDF returns BinaryContent(media_type="application/pdf") so capable models (OpenAI/Anthropic/Gemini) can read it directly.
    • Internally, read_file (both edit_format variants) now delegates to two clearly-named helpers — _maybe_image_content and _maybe_document_content — over a shared _read_binary_within_limit (not-found/empty + size-limit guards), removing the prior duplication between the two read_file definitions while keeping the image and document seams independent for future per-kind handling (e.g. OCR for images vs. native document understanding / text extraction for PDF/DOCX).