Repository navigation
feat: local PDF extraction with poppler (no external service) - #22
Merged
Merged
Conversation
Video messages and video/* documents were rejected as unsupported, so a walkthrough clip sent to the bot was dropped. They are now downloaded (<=20 MB, Telegram Bot API limit), saved to the agent upload dir (LOCAL_VISION_UPLOAD_DIR, same as photos), and the saved path is appended to the prompt so the agent can process the original file locally (e.g. extract frames with ffmpeg). Oversize videos get a clear file_too_large reply before downloading; media groups with videos stay unsupported.
This was referenced Sep 26, 2026
…tion # Conflicts: # src/bot/handlers/document-handler.ts # tests/bot/handlers/document.test.ts
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.
What
PDFs sent to the bot were dropped when the active model does not support PDF input (
input.pdf === false, e.g.opencode-go/deepseek-v4.1-flash) and noDOC_EXTRACTOR_URLwas configured — the user gotbot.model_no_pdfand the file was lost:This adds local PDF extraction with poppler-utils: no external service, no new dependencies.
pdftotextthrough stdin (nothing written to disk; text capped at 100k chars with a truncation note).pdftoppmto JPEG and sent as image parts when the model supports image input; otherwisebot.document_extraction_error(plus caption fallback).DOC_EXTRACTOR_URL(now only needed for non-PDF office formats or hosts without poppler).Tests
tests/app/services/local-pdf-extractor-service.test.ts(9 cases): availability, text extraction, truncation, error paths with mocked spawn + real-poppler smoke tests (skipped when poppler is absent, so CI stays green).document.test.ts: 6 new cases — local text flow, truncation note, local-over-remote preference, scanned page images, scanned-without-image-support error, extraction failure fallback.bun run checkgreen: lint + build + 1840 tests pass (0 fail).Notes
pdftotext,pdftoppm,pdfinfo) on the host; already present on the deploy machine (Fedora, poppler-utils 26.01).model_no_pdf).