From 953b3e1b3f94ee137d20a68edbf9cf57004b8f28 Mon Sep 17 00:00:00 2001 From: Stephen Hu Date: Tue, 6 May 2025 17:38:22 +0800 Subject: [PATCH] Fix: Sometimes VisionFigureParser.figures may is tuple (#7477) ### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/7466 I think due to some times we can not get position ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- deepdoc/parser/figure_parser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/deepdoc/parser/figure_parser.py b/deepdoc/parser/figure_parser.py index 24b030716..1431011fe 100644 --- a/deepdoc/parser/figure_parser.py +++ b/deepdoc/parser/figure_parser.py @@ -51,8 +51,13 @@ class VisionFigureParser: self.positions.append(item[1]) else: assert len(item) == 2 and isinstance(item, tuple) and isinstance(item[1], list), f"get {len(item)=}, {item=}" - self.figures.append(item[0]) - self.descriptions.append(item[1]) + if isinstance(item[0], tuple) and len(item[0]) == 2 and isinstance(item[0][0], Image.Image) and isinstance(item[0][1], list): + self.figures.append(item[0][0]) + self.descriptions.append(item[0][1]) + else: + self.figures.append(item[0]) + self.descriptions.append(item[1]) + def _assemble(self): self.assembled = []