fix: Proper support for VLM in Docling#10094
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds mlx-vlm dependency. Updates four starter project templates to embed a Docling-enabled FileComponent that can offload parsing to a subprocess with optional VLM/OCR pipelines and dynamic outputs. Adjusts lfx file component to simplify Docling imports, refine VLM construction (including optional mlx_vlm on macOS), and raise errors on failures. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant FC as FileComponent (starter templates)
participant SP as Subprocess (Docling Runner)
participant DL as Docling/VLM Pipelines
U->>FC: Provide file(s) and options (advanced, pipeline, OCR, placeholders)
alt Single file & Docling-compatible & advanced enabled
FC->>SP: Launch subprocess with JSON config
SP->>DL: Initialize converters (standard/VLM) and parse
DL-->>SP: Parsed result (markdown/structured/meta)
SP-->>FC: JSON result or error
opt UNNEST single-file outputs
FC->>FC: Map to Raw/Markdown/Structured outputs
end
else Multi-file or non-compatible
FC->>FC: Standard/parallel file loading
end
FC-->>U: Outputs (Raw Content, Markdown, Structured, File Path, Meta)
note over FC,SP: Errors are propagated (no silent VLM fallback)
note over FC: On macOS, mlx_vlm may be enabled if available
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 error, 1 warning)
✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json (1)
2270-2470: Fix missing VLM imports in the Docling subprocess.When
pipeline == "vlm", the child script referencesVlmPipelineOptionsandvlm_model_specswithout ever importing them, so the block raisesNameErrorand falls back to the plainDocumentConverter. As a result, the advertised VLM path never runs. Pull the proper symbols from Docling (and actually wire the options intoPdfFormatOption) so the VLM pipeline executes.- if pipeline == "vlm": - try: - from docling.pipeline.vlm_pipeline import VlmPipeline - from docling.document_converter import PdfFormatOption # type: ignore - - vl_pipe = VlmPipelineOptions( - vlm_options=vlm_model_specs.GRANITEDOCLING_TRANSFORMERS, - ) + if pipeline == "vlm": + try: + from docling.pipeline.vlm_pipeline import VlmPipeline, VlmPipelineOptions # type: ignore + from docling.datamodel import vlm_model_specs # type: ignore + from docling.document_converter import PdfFormatOption # type: ignore + + vl_pipe = VlmPipelineOptions( + vlm_options=vlm_model_specs.GRANITEDOCLING_TRANSFORMERS, + ) @@ - if hasattr(input_format, "PDF"): - fmt[getattr(input_format, "PDF")] = PdfFormatOption(pipeline_cls=VlmPipeline) - if hasattr(input_format, "IMAGE"): - fmt[getattr(input_format, "IMAGE")] = PdfFormatOption(pipeline_cls=VlmPipeline) + if hasattr(input_format, "PDF"): + fmt[getattr(input_format, "PDF")] = PdfFormatOption( + pipeline_cls=VlmPipeline, + pipeline_options=vl_pipe, + ) + if hasattr(input_format, "IMAGE"): + fmt[getattr(input_format, "IMAGE")] = PdfFormatOption( + pipeline_cls=VlmPipeline, + pipeline_options=vl_pipe, + )src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)
1120-1188: Fix undefined VLM dependencies in the child scriptWhen the user selects
pipeline="vlm", the subprocess hits aNameErrorbecauseVlmPipelineOptionsandvlm_model_specsare referenced but never imported inside the child script. That crash makes the new VLM path unusable.Please import those symbols before they’re used (e.g.,
from docling.pipeline.vlm_pipeline import VlmPipeline, VlmPipelineOptionsandfrom docling.datamodel import vlm_model_specs, or pull the concrete constants directly) so the VLM branch can execute.src/lfx/src/lfx/components/data/file.py (1)
360-377: Wire VLM pipeline options into PdfFormatOption
vl_pipe(with GRANITEDOCLING specs and optional MLX switch) is never handed toPdfFormatOption, so the VLM pipeline always falls back to defaults and the new mlx_vlm path never activates. Please passpipeline_options=vl_pipewhen constructing the format options for both PDF and IMAGE inputs.Apply this diff:
- if hasattr(input_format, "PDF"): - fmt[getattr(input_format, "PDF")] = PdfFormatOption(pipeline_cls=VlmPipeline) - if hasattr(input_format, "IMAGE"): - fmt[getattr(input_format, "IMAGE")] = PdfFormatOption(pipeline_cls=VlmPipeline) + if hasattr(input_format, "PDF"): + fmt[getattr(input_format, "PDF")] = PdfFormatOption( + pipeline_cls=VlmPipeline, + pipeline_options=vl_pipe, + ) + if hasattr(input_format, "IMAGE"): + fmt[getattr(input_format, "IMAGE")] = PdfFormatOption( + pipeline_cls=VlmPipeline, + pipeline_options=vl_pipe, + )src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json (1)
2800-2885: VLM pipeline never initializes due to missing imports
Inside the embedded Docling subprocess script,VlmPipelineOptionsandvlm_model_specsare used but never imported. At runtime this raises aNameError, tripping theexceptblock and silently falling back to the defaultDocumentConverter, so the newvlmpipeline path is effectively non-functional. Please import the needed symbols (e.g.from docling.pipeline.vlm_pipeline import VlmPipeline, VlmPipelineOptionsandfrom docling.datamodel import vlm_model_specs) and wire them into the converter setup so the VLM branch actually runs.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
pyproject.toml(1 hunks)src/backend/base/langflow/initial_setup/starter_projects/Document Q&A.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Text Sentiment Analysis.json(2 hunks)src/backend/base/langflow/initial_setup/starter_projects/Vector Store RAG.json(2 hunks)src/lfx/src/lfx/components/data/file.py(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
- GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
- GitHub Check: Lint Backend / Run Mypy (3.13)
- GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
- GitHub Check: Test Starter Templates
- GitHub Check: Optimize new Python code in this PR
- GitHub Check: Update Starter Projects
- GitHub Check: test-starter-projects
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10094 +/- ##
==========================================
- Coverage 24.21% 24.17% -0.05%
==========================================
Files 1086 1086
Lines 40044 40044
Branches 5541 5541
==========================================
- Hits 9696 9679 -17
- Misses 30177 30194 +17
Partials 171 171
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* feat: Tool Mode Support for File Components * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat: Better support for advanced parser in files * [autofix.ci] apply automated fixes * Add docling mocked tests * Update file.py * Update test_file_component.py * [autofix.ci] apply automated fixes * Update News Aggregator.json * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
|



This pull request introduces a new dependency and updates project metadata. The most significant changes are as follows:
Dependency Updates
mlx-vlmversion>=0.0.7to the list of dependencies inpyproject.toml.Project Metadata
code_hashvalue in theDocument Q&A.jsonstarter project to reflect the latest code state.Summary by CodeRabbit
New Features
Improvements
Chores