Fix: support vlm fall back in pipeline (#14007)

### What problem does this PR solve?

Fix: support vlm fall back in pipeline for img/table parsing

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Magicbook1108
2026-04-09 20:20:11 +08:00
committed by GitHub
parent 5951e2b564
commit 52f5880d21
2 changed files with 19 additions and 24 deletions

View File

@@ -625,15 +625,12 @@ class Parser(ProcessBase):
if abstract_idx is not None:
bboxes[abstract_idx]["abstract"] = True
print(conf.get("vlm"))
if conf.get("vlm"):
enhance_media_sections_with_vision(
bboxes,
self._canvas._tenant_id,
conf["vlm"],
callback=self.callback,
)
enhance_media_sections_with_vision(
bboxes,
self._canvas._tenant_id,
conf.get("vlm"),
callback=self.callback,
)
# Emit the requested final PDF output format.
if conf.get("output_format") == "json":
@@ -804,13 +801,12 @@ class Parser(ProcessBase):
"doc_type_kwd": "table",
}
)
if conf.get("vlm"):
enhance_media_sections_with_vision(
sections,
self._canvas._tenant_id,
conf["vlm"],
callback=self.callback,
)
enhance_media_sections_with_vision(
sections,
self._canvas._tenant_id,
conf.get("vlm"),
callback=self.callback,
)
self.set_output("json", sections)
@@ -930,13 +926,12 @@ class Parser(ProcessBase):
json_result["doc_type_kwd"] = "image" if json_result.get("image") is not None else "text"
json_results.append(json_result)
if conf.get("vlm"):
enhance_media_sections_with_vision(
json_results,
self._canvas._tenant_id,
conf["vlm"],
callback=self.callback,
)
enhance_media_sections_with_vision(
json_results,
self._canvas._tenant_id,
conf.get("vlm"),
callback=self.callback,
)
self.set_output("json", json_results)
else:
self.set_output("text", "\n".join([section_text for section_text, _ in sections]))

View File

@@ -125,7 +125,7 @@ def enhance_media_sections_with_vision(
vlm_conf=None,
callback=None,
):
if not sections or not tenant_id or not vlm_conf:
if not sections or not tenant_id:
return sections
try: