Skip to content

Commit

Permalink
ignore linked images when image id is none (langgenius#7890)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored and cuiks committed Sep 26, 2024
1 parent dd05339 commit 98baff4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/core/rag/extractor/word_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def _parse_cell_paragraph(self, paragraph, image_map):
if run.element.xpath('.//a:blip'):
for blip in run.element.xpath('.//a:blip'):
image_id = blip.get("{http://schemas.openxmlformats.org/officeDocument/2006/relationships}embed")
if not image_id:
continue
image_part = paragraph.part.rels[image_id].target_part

if image_part in image_map:
Expand Down Expand Up @@ -256,6 +258,6 @@ def parse_paragraph(paragraph):
content.append(parsed_paragraph)
elif isinstance(element.tag, str) and element.tag.endswith('tbl'): # table
table = tables.pop(0)
content.append(self._table_to_markdown(table,image_map))
content.append(self._table_to_markdown(table, image_map))
return '\n'.join(content)

0 comments on commit 98baff4

Please sign in to comment.