fix: harden long PDF page extraction#85
Open
gwokhou wants to merge 1 commit into
Open
Conversation
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.
Summary
This PR hardens long PDF page extraction in
index_long_document().It normalizes page content returned by PageIndex Cloud or the local PDF fallback into OpenKB's expected source JSON shape, including support for common page fields such as
page,page_number,page_num,content,markdown, andtext.Why
Long PDF indexing currently assumes that page extraction returns data in the exact shape OpenKB later writes to
wiki/sources/*.json. In practice, cloud/local extractors may returnstrings, alternate page-number fields, alternate content fields, invalid image metadata, or empty/unusable page data.
That can lead to brittle downstream behavior during wiki compilation, especially for complex or lengthy PDFs.
Related to #77. This does not replace the default PDF parser, but it improves the resilience of the existing PageIndex/local PDF extraction path.
Changes
_normalize_page_content()for PageIndex/local PDF page outputs.get_page_content()responses before writing source JSON.RuntimeErrorwhen both cloud and local extraction produce no usable page content.Testing
tests/test_indexer.py.