Playground: snap hover bboxes to the PDF text layer + show partial extractions - #5
Merged
Merged
Conversation
…tractions Rescues hover highlights whose model-reported provenance is missing or wrong by locating each field's value in the PDF text layer (new snap.ts): builds visual lines from positioned text runs, matches the value's textual forms (incl. formatted currency), and snaps to the nearest occurrence, searching across pages to fix null/out-of-range page indices. Images, which have no text layer, keep drawing the model's own bbox. Surface partial results on a MissingRequiredFieldsError: the server carries the extracted-so-far data/fields/usage on the ApiError, and the client renders them under the error banner. Add Gemini 3.5 Flash to the playground catalog and the demo GIF to the README. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Improves the playground's killer interaction — hover a JSON field → highlight its source region — and makes failed runs more useful.
Hover bbox accuracy (
snap.ts)Rescues hover highlights whose model-reported provenance is missing or wrong by locating each field's value in the PDF text layer:
6000→$6,000.00), case-insensitively, rejecting matches glued to other word characters.Partial extractions on error
On a
MissingRequiredFieldsError, the server now carries the extracted-so-fardata/fields/usageon theApiError, and the client renders it under the error banner instead of showing nothing.Misc
Tests
New
snap.test.tscovers candidate string generation, snapping, cross-page location, and rescue cases.app.test.tscovers the partial-extraction error path.🤖 Generated with Claude Code