feat(adk/backend/local): add MultiModalRead for images and PDFs#814
Open
feat(adk/backend/local): add MultiModalRead for images and PDFs#814
Conversation
Add MultiModalRead to *Local that returns structured multimodal content for image and PDF files, with fallback to Read for other types. Images: - Read raw bytes via local os.ReadFile (stat-based size pre-check) - Detect MIME type via magic-number headers (PNG/JPEG/GIF/BMP/WebP/TIFF) - Enforce 10 MB size limit PDFs: - Full read (no 'pages'): return raw PDF bytes, 20 MB limit - Paged read (with 'pages'): stream pages directly from disk via fitz.New(path) (avoids loading the file into memory), render the page range to PNG at 150 DPI, 100 MB size limit, max 20 pages per request - Validate 'pages' parameter syntax and ranges upfront - Clamp end page with warning when it exceeds total page count - ctx-aware render loop: cancelled context aborts between pages Size enforcement: - Stat-based primary check rejects oversize files before allocation - Secondary length sanity check after ReadFile - Actionable error messages (e.g. suggest 'pages' param when full-read limit is exceeded) - not-exist errors wrap os.ErrNotExist so callers keep errors.Is semantics Also: - Bump go directive to 1.23; upgrade eino to v0.9.0-alpha.5.0.2026... to pick up MultiModalRead types - Add go-fitz (MuPDF via purego/ffi) dependency; README documents the native library install commands per OS - Add table-driven tests for parsePagesParam, detectImageMIME, and the MultiModalRead branches (text fallback, image, oversize image, full/paged PDF, invalid pages) - Update examples/backend/main.go with a MultiModalRead demo and fix the stale middlewares/filesystem import path
Need to create a new tagThe following modules have changes and may need version updates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add MultiModalRead to *Local that returns structured multimodal content for image and PDF files, with fallback to Read for other types.
Images:
PDFs:
Size enforcement:
Also: