Repository navigation
fix(deepdoc): propagate dataset language through all 4 figure-vision wrappers - #17677
Harsh23Kashyap wants to merge 0 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughFigure parsing now accepts document language through DOCX, PDF, and Excel paths. Vision wrappers, model bundles, parser instances, and prompts propagate the language. Prompt templates define translated generated fields while preserving visible text. Regression tests cover defaults, forwarding, and prompt rendering. ChangesFigure language propagation
Estimated code review effort: 3 (Moderate) | ~25 minutes Mergeability Score: ⚪ Minimal · up to This change propagates dataset language through all figure-description paths and reports passing targeted tests and checks; no actionable merge-blocking risk remains beyond normal review. Sequence Diagram(s)sequenceDiagram
participant Application
participant FigureWrapper
participant LLMBundle
participant VisionFigureParser
participant PromptGenerator
Application->>FigureWrapper: pass document language
FigureWrapper->>LLMBundle: initialize with language
FigureWrapper->>VisionFigureParser: construct with language
VisionFigureParser->>PromptGenerator: render figure prompt with language
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deepdoc/parser/figure_parser.py`:
- Around line 49-80: Normalize the lang parameter at the start of both vision
figure wrapper functions, vision_figure_parser_docx_wrapper and
vision_figure_parser_figure_xlsx_wrapper, so empty values fall back to
"English". Use the normalized lang for every LLMBundle, VisionFigureParser, and
figure-prompt call in these wrappers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 60ec27c7-30a7-4ce3-a239-e036ccbcb5ce
📒 Files selected for processing (11)
deepdoc/parser/figure_parser.pyrag/app/book.pyrag/app/manual.pyrag/app/naive.pyrag/app/one.pyrag/app/paper.pyrag/app/table.pyrag/prompts/generator.pyrag/prompts/vision_llm_figure_describe_prompt.mdrag/prompts/vision_llm_figure_describe_prompt_with_context.mdtest/unit_test/deepdoc/parser/test_figure_parser.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17677 +/- ##
==========================================
- Coverage 94.56% 90.65% -3.91%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 650 -28
- Misses 25 39 +14
- Partials 14 28 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Before merging, please: 1) apply CodeRabbit's |
…on wrappers Per @xugangqiang's review on infiniflow#17677: the wrappers' lang="English" default is bypassed when an empty string is forwarded (the default only fires when the kwarg is missing). Apply the same 'lang = lang or default' normalization at the wrapper boundary in all 4 figure-vision wrappers (docx, xlsx, pdf, naive), so the figure-description prompt always gets a real language and the dataset's empty-language fallback is never silently dropped. Adds 4 new test cases (one per wrapper) covering the empty-string fallback.
|
Both done in 12a3ab2 (force-pushed over the previous tip).
One scope note for review: the |
|
@Harsh23Kashyap Would you please resolve the conflicts? |
|
Cherry-picked the commits onto current |
12a3ab2 to
c87aa3b
Compare
fix(deepdoc): propagate dataset language through all 4 figure-vision wrappers
Fixes #17280. Supersedes the partial PR #17227 (still OPEN, never landed).
Problem
PR #17227 fixed the dataset language propagation for the
vision_figure_parser_docx_wrapper_naivepath, but three other wrappers indeepdoc/parser/figure_parser.pyhad the same bug: they never receivedlang, soVisionFigureParser.self.languagealways defaulted to"English"and the figure-description prompt's{{ language }}variable always rendered as English.Affected paths
lang=lang)vision_figure_parser_docx_wrapperdeepdoc/parser/figure_parser.py:49rag/app/book.py:89,rag/app/manual.py:286vision_figure_parser_figure_xlsx_wrapperdeepdoc/parser/figure_parser.py:69rag/app/table.py:83(also forwardlangthroughExcel.__call__)vision_figure_parser_pdf_wrapperdeepdoc/parser/figure_parser.py:102rag/app/naive.py:122(by_deepdoc),rag/app/manual.py:267,rag/app/paper.py:183vision_figure_parser_docx_wrapper_naivedeepdoc/parser/figure_parser.py:144rag/app/naive.py:1031,rag/app/one.py:86Root cause
Every
chunk()function inrag/app/{book,manual,naive,one,paper,table}.pydeclareslang="Chinese"as a named parameter, solangis captured and is not in**kwargs. The wrappers received**kwargsonly, solangnever reachedVisionFigureParser.__init__, andself.language = kwargs.get("lang") or "English"always fell back to"English".Fix
This PR also picks up the supporting changes that PR #17227 introduced for the
_naivewrapper (since PR #17227 is still open and depends on the sameVisionFigureParser.__init__and prompt changes):VisionFigureParser.__init__storesself.languagefrom thelangkwarg (default"English").vision_llm_figure_describe_prompt(language=...)andvision_llm_figure_describe_prompt_with_context(..., language=...)accept and render thelanguageargument..mdtemplates now include a## OUTPUT LANGUAGEsection that uses{{ language }}.Files changed
deepdoc/parser/figure_parser.pylang="English"to 4 wrappers;VisionFigureParser.__init__storesself.language;__call__worker passeslanguage=self.languageto both prompt functionsrag/app/book.pylang=langtovision_figure_parser_docx_wrapperrag/app/manual.pylang=langto both wrapper callsrag/app/naive.pylang=langtovision_figure_parser_pdf_wrapper(inby_deepdoc) andvision_figure_parser_docx_wrapper_naiverag/app/one.pylang=langtovision_figure_parser_docx_wrapper_naiverag/app/paper.pylang=langtovision_figure_parser_pdf_wrapperrag/app/table.pylang=langtovision_figure_parser_figure_xlsx_wrapper;Excel.__call__accepts and forwardslangrag/prompts/generator.pyvision_llm_figure_describe_prompt(language=...)andvision_llm_figure_describe_prompt_with_context(..., language=...)accept the argumentrag/prompts/vision_llm_figure_describe_prompt.md## OUTPUT LANGUAGEsection with{{ language }}rag/prompts/vision_llm_figure_describe_prompt_with_context.md## OUTPUT LANGUAGEsection with{{ language }}test/unit_test/deepdoc/parser/test_figure_parser.pyDiff: 11 files changed, 67 insertions(+), 23 deletions(-).
Tests
15 p0 tests, three layers:
TestPromptLanguageVariable(4) -- the figure-description prompt functions accept alanguageargument and render{{ language }}in the prompt (default"English",Chinese/Japanesewhen passed).TestVisionFigureParserLanguage(3) --VisionFigureParserstoresself.languagefrom thelangkwarg, defaults to"English"when omitted, falls back on empty string.TestDocxWrapperForwardsLang(2),TestXlsxWrapperForwardsLang(1),TestPdfWrapperForwardsLang(1),TestNaiveDocxWrapperForwardsLang(2) -- each of the 4 wrappers forwardslangto bothLLMBundleandVisionFigureParser. The_naivewrapper additionally forwardslanguage=langto both prompt functions in its per-chunk worker (with and without context).TestPromptReceivesParserLanguage(2) -- end-to-end:VisionFigureParser.__call__passesself.languageto the prompt functions in its process worker.All 15 tests pass locally:
$ .venv/bin/python -m pytest test/unit_test/deepdoc/parser/test_figure_parser.py -v ============================== 15 passed in 3.42s ==============================Lint / format
Out of scope
LLMBundle(lang=)does not currently affect figure descriptions (the prompt{{ language }}is what controls the output language --describe_with_prompt()inrag/llm/cv_model.py:353does not readself.lang).LLMBundle(lang=lang)is still passed here for consistency with the non-figure LLM call sites.Notes
PR #17227 (a prior partial fix for the same problem) is still OPEN. This PR is a strict superset: it covers all 4 wrappers (vs PR #17227's 1 wrapper) and includes the supporting prompt +
VisionFigureParser.__init__changes that PR #17227 needs. When this PR lands, #17227 should be closed as superseded.