Update to anchorite 0.2.0 and delegate core functionality to library#6
Update to anchorite 0.2.0 and delegate core functionality to library#6
Conversation
- Propagate mime_type to document chunks - Add simplified magic number inference for images - Add tests for mime type inference and propagation
- Delegate bbox alignment, document chunking, range ops, and settings to anchorite 0.2.0, removing the internal copies (bbox_alignment.py, document.py, range_ops.py, settings.py) - Update Anchor construction: box= (singular) → boxes= (tuple of BBox) - Update fitz → pypdfium2 mocks in tests (anchorite.document now uses pypdfium2) - Fix missing `class` keyword in _LayoutProcessor (syntax error) - Convert hubble_docai_bboxes fixture from pickle (anchorite.types) to JSON - Regenerate golden files for new multi-box span format - Bump version to 0.5.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a major refactoring by migrating the core document processing logic to use the anchorite library. This involves removing internal document, bbox_alignment, and settings modules, and replacing them with anchorite's DocumentChunk, AnchorProvider, and MarkdownProvider interfaces. The pyproject.toml was updated to reflect the new anchorite dependency and remove seq-smith. The run_ocr.py script was enhanced to accept an optional --gemini-prompt argument. The Document AI and Gemini integration modules (docai.py, docai_layout.py, docai_ocr.py, gemini.py) were refactored into provider classes (DocAIMarkdownProvider, DocAIAnchorProvider, GeminiMarkdownProvider) that implement anchorite's provider interfaces, centralizing configuration and logic. The main gemini_ocr.py module was updated to use these new providers and the anchorite.process_document function, simplifying the overall document processing workflow and allowing providers to be built from environment variables via a new from_env function.
Replace all `from x import ClassName` with module-level imports and qualified names throughout src/ and tests/ to match Google Python Style Guide requirements.
Replace all `import anchorite.document` / `import anchorite.providers` with a single `import anchorite`, relying on anchorite's __init__.py re-exporting its submodules.
Remove process_document wrapper — callers now use anchorite.process_document directly. gemini_ocr's public API is now the provider classes and from_env().
Summary
bbox_alignment, document chunking,range_ops, and settings to anchorite 0.2.0, removing the internal copiesAnchorconstruction frombox=BBox(...)(singular) toboxes=(BBox(...),)(tuple) to match the new APIfitz/anchorite.document.fitzmocks topypdfium2mocks, sinceanchorite.documentnow uses pypdfium2classkeyword in_LayoutProcessorhubble_docai_bboxesfixture from pickle (referencedanchorite.typeswhich no longer exists) to JSONTest plan
ruff check+ruff format)🤖 Generated with Claude Code