From 2cb1046cbf0e517b10186036515a407f7d6653af Mon Sep 17 00:00:00 2001 From: YngvarHuang <625452882@qq.com> Date: Fri, 7 Nov 2025 11:46:10 +0800 Subject: [PATCH] fix: The doc file cannot be parsed(#11092) (#11093) ### What problem does this PR solve? The doc file cannot be parsed(#11092) ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: virgilwong --- rag/app/naive.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rag/app/naive.py b/rag/app/naive.py index 631050a49..886d40e99 100644 --- a/rag/app/naive.py +++ b/rag/app/naive.py @@ -724,8 +724,15 @@ def chunk(filename, binary=None, from_page=0, to_page=100000, elif re.search(r"\.doc$", filename, re.IGNORECASE): callback(0.1, "Start to parse.") + try: + from tika import parser as tika_parser + except Exception as e: + callback(0.8, f"tika not available: {e}. Unsupported .doc parsing.") + logging.warning(f"tika not available: {e}. Unsupported .doc parsing for {filename}.") + return [] + binary = BytesIO(binary) - doc_parsed = parser.from_buffer(binary) + doc_parsed = tika_parser.from_buffer(binary) if doc_parsed.get('content', None) is not None: sections = doc_parsed['content'].split('\n') sections = [(_, "") for _ in sections if _]