RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: Embedding err when docx contains unsupported images (#1720)
Yuhao Tsuia973b9e01fa0
diff --git a/rag/app/naive.py b/rag/app/naive.pyindex ccb357e5e3..a2ba6993c8 100644--- a/rag/app/naive.py+++ b/rag/app/naive.py@@ -23,7 +23,7 @@ from rag.utils import num_tokens_from_stringfrom PIL import Imagefrom functools import reducefrom markdown import markdown-+from docx.image.exceptions import UnrecognizedImageErrorclass Docx(DocxParser):def __init__(self):@@ -36,9 +36,16 @@ class Docx(DocxParser):img = img[0]embed = img.xpath('.//a:blip/@r:embed')[0]related_part = document.part.related_parts[embed]- image = related_part.image- image = Image.open(BytesIO(image.blob)).convert('RGB')- return image+ try:+ image_blob = related_part.image.blob+ except UnrecognizedImageError:+ print("Unrecognized image format. Skipping image.")+ return None+ try:+ image = Image.open(BytesIO(image_blob)).convert('RGB')+ return image+ except Exception as e:+ return Nonedef __clean(self, line):line = re.sub(r"\u3000", " ", line).strip()