Repository navigation
fix(figure_parser): accept lang as named parameter on VisionFigureParser (#17280) - #19511
Conversation
…ser (infiniflow#17280) `VisionFigureParser.__init__` previously took `\*args, \*\*kwargs` and read the dataset language via `kwargs.get("lang")`. The three wrappers above pass `lang=lang` as an explicit keyword argument, so `kwargs.get("lang")` did return the value — but the contract was implicit and easy to miss when adding new call sites (any caller that forgets `lang=` and only forwards `\*\*kwargs` would silently default to English). Make `lang` an explicit named parameter so the type system catches the omission and the value is normalized via `_normalize_vision_language` for consistency with the wrappers' own handling. `\*\*kwargs.get("lang")` is kept as a fallback so older callers that don't pass `lang` keep working. No behavior change for any current call site.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesVision language handling
Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Vision figure parsing now receives an explicit normalized language while preserving legacy callers and the English default. No current correctness or operational risk remains, so this change is mergeable. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The change formalizes lang in VisionFigureParser, but it does not implement the linked issue's required wrapper and caller changes. The three wrappers still need to accept and forward lang, and the XLSX path still needs to forward lang through Excel.call [ Resolution Update the three vision wrapper functions to accept lang, pass lang=lang to VisionFigureParser and LLMBundle where required, update all affected callers, and forward lang through Excel.call for the XLSX path. Add or verify tests for each affected path [
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. A rabbit checks the language flow, Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19511 +/- ##
==========================================
+ Coverage 29.85% 37.32% +7.47%
==========================================
Files 54 54
Lines 15343 15374 +31
Branches 118 125 +7
==========================================
+ Hits 4580 5739 +1159
+ Misses 10751 9608 -1143
- Partials 12 27 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
"Fixes #17280.\n\nRe-opened as a clean PR per JinHai-CN's request \u2014 the previous #18392 had 929k insertions and 111k deletions because it carried the full main-sync history forward from when the branch was first cut. This version is the same 7-line fix (now +9 / -2) rebased onto current
upstream/main, with no unrelated changes.\n\n## Problem\n\nVisionFigureParser.__init__previously took*args, **kwargsand read the dataset language viakwargs.get(\"lang\"). The three wrappers above passlang=langas an explicit keyword argument, sokwargs.get(\"lang\")did return the value \u2014 but the contract was implicit and easy to miss when adding new call sites. Any caller that forgetslang=and only forwards**kwargswould silently default to English.\n\n## Fix\n\ndeepdoc/parser/figure_parser.py\u2014 makelangan explicit named parameter onVisionFigureParser.__init__. The type system now catches the omission, and the value is normalized via the existing_normalize_vision_languagehelper (mirroring the wrappers' own handling) for consistency.**kwargs.get(\"lang\")is kept as a fallback so older callers that don't passlangkeep working.\n\npython\ndef __init__(self, vision_model, figures_data, *args, lang=\"English\", **kwargs):\n ...\n self.language = _normalize_vision_language(lang) or kwargs.get(\"lang\") or \"English\"\n\n\nNo behavior change for any existing call site.\n\n## Tests\n\ntest/unit_test/deepdoc/parser/test_figure_parser.py\u2014 the existingtest_vision_figure_parser_passes_dataset_language_to_prompt[language]parametrized test already covers the named-parameter forward path; it pinsvision_llm_figure_describe_promptis called with the normalized language.test_figure_wrappers_pass_dataset_language_to_model_and_parsercovers the three wrappers' end-to-end path.\n\nDiff: +9 / -2 across 1 file.mergeable: MERGEABLE.\n"