refactor VLM configuration to use dependency pattern#78
Merged
AdemBoukhris457 merged 5 commits intomainfrom Nov 9, 2025
Merged
refactor VLM configuration to use dependency pattern#78AdemBoukhris457 merged 5 commits intomainfrom
AdemBoukhris457 merged 5 commits intomainfrom
Conversation
Replace individual VLM parameters (use_vlm, vlm_provider, vlm_model vlm_api_key) with VLMStructuredExtractor instance dependency in all parser classes. Update CLI and UI components to create VLM engines externally before passing to parsers. This provides clearer API, prevents configuration conflicts, and enables VLM engine reuse across multiple parsers.
Replace individual VLM parameters (use_vlm, vlm_provider, vlm_model vlm_api_key) with VLMStructuredExtractor instance dependency in all parser classes. Update CLI and UI components to create VLM engines externally before passing to parsers. This provides clearer API, prevents configuration conflicts, and enables VLM engine reuse across multiple parsers.
Replace individual VLM parameters (use_vlm, vlm_provider, vlm_model vlm_api_key) with VLMStructuredExtractor instance dependency in all parser classes. Update CLI and UI components to create VLM engines externally before passing to parsers. This provides clearer API, prevents configuration conflicts, and enables VLM engine reuse across multiple parsers.
Update all VLM usage examples in README.md to show VLMStructuredExtractor initialization and passing to parsers. Add VLM Engine Configuration section and update all parser examples to reflect the new API.
Update all documentation files to show VLMStructuredExtractor initialization and passing to parsers. Replace all examples using individual VLM parameters (use_vlm, vlm_provider, ...) with the new dependency pattern where VLM engines are created externally.
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 MR refactors VLM (Vision Language Model) configuration across all parser classes to use a dependency pattern, similar to the previous OCR engine refactoring. Instead of exposing individual VLM parameters (
use_vlm,vlm_provider,vlm_model,vlm_api_key) directly in parser constructors, users now initialize aVLMStructuredExtractorinstance externally and pass it to the parser.Changes
Code Changes
StructuredPDFParser,EnhancedPDFParser,ChartTablePDFParser, andStructuredDOCXParserto accept an optionalvlm: Optional[VLMStructuredExtractor]parameterparse,enhance,parse-docx,extract) to createVLMStructuredExtractorinstances before passing to parsersgradio_app.py,hf_space/app.py,hf_space/app_fixed.py,doctra/ui/full_parse_ui.py,doctra/ui/enhanced_parser_ui.py) to create VLM engine instances based on user inputsDocumentation Changes
Benefits
Migration Guide
Before:
After: