From 6b1221d2f64eb20a17134eafe59440148c985064 Mon Sep 17 00:00:00 2001 From: Tuan Le <30828528+tuankg1028@users.noreply.github.com> Date: Thu, 26 Jun 2025 10:54:43 +0700 Subject: [PATCH] Fix parser_config access for layout_recognize in presentation.py (#8492) ### What problem does this PR solve? This PR addresses an issue in the presentation parser where the `layout_recognize` configuration was incorrectly retrieved from `kwargs.get("layout_recognize", "DeepDOC")`. Instead, it should be sourced from the `parser_config` parameter, specifically `parser_config.get("layout_recognize", "DeepDOC")`. This mismatch could cause the parser to default to the "DeepDOC" layout recognizer, ignoring any alternative recognition method specified in the parser configuration. As a result, PDF document parsing might use an incorrect recognition engine. The fix ensures the presentation parser consistently uses the `layout_recognize` setting from `parser_config`, aligning with the configuration access patterns used elsewhere in the codebase. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/app/presentation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rag/app/presentation.py b/rag/app/presentation.py index fd32c261b..45f72adf5 100644 --- a/rag/app/presentation.py +++ b/rag/app/presentation.py @@ -98,12 +98,14 @@ class PlainPdf(PlainParser): def chunk(filename, binary=None, from_page=0, to_page=100000, - lang="Chinese", callback=None, **kwargs): + lang="Chinese", callback=None, parser_config=None, **kwargs): """ The supported file formats are pdf, pptx. Every page will be treated as a chunk. And the thumbnail of every page will be stored. PPT file will be parsed by using this method automatically, setting-up for every PPT file is not necessary. """ + if parser_config is None: + parser_config = {} eng = lang.lower() == "english" doc = { "docnm_kwd": filename, @@ -126,7 +128,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000, res.append(d) return res elif re.search(r"\.pdf$", filename, re.IGNORECASE): - layout_recognizer = kwargs.get("layout_recognize", "DeepDOC") + layout_recognizer = parser_config.get("layout_recognize", "DeepDOC") if layout_recognizer == "DeepDOC": pdf_parser = Pdf() sections = pdf_parser(filename, binary, from_page=from_page, to_page=to_page, callback=callback)