fix(docreader): remove default 100-page limit for DOCX parsing

The default DOCREADER_DOCX_MAX_PAGES=100 silently truncates large
documents, causing users to see at most ~1000 chunks regardless of
document length. Change the default to 0 (no limit) so all pages are
processed. Operators who need a cap can still set the env var.

Fixes #719
This commit is contained in:
wizardchen
2026-04-28 21:43:13 +08:00
committed by lyingbug
parent 80a007cc06
commit d5f6c7ba21
3 changed files with 6 additions and 4 deletions
+3 -3
View File
@@ -386,9 +386,9 @@ DOCREADER_ADDR=docreader:50051
# Docreader 连接方式
DOCREADER_TRANSPORT=grpc
# Docreader 中 DOCX 解析的最大页数,默认 100
# 用于限制超大 Word 文档的解析开销;超过页数的内容将不会继续解析
# DOCREADER_DOCX_MAX_PAGES=100
# Docreader 中 DOCX 解析的最大页数,默认 0(不限制)
# 设为正整数(如 500)可限制超大 Word 文档的解析开销;超过页数的内容将不会继续解析
# DOCREADER_DOCX_MAX_PAGES=0
# 如果使用Weaviate作为向量存储,需要配置以下参数
# 注意:容器内访问请使用 service:port(不要用 localhost,也不要用宿主机映射端口)
+1 -1
View File
@@ -73,7 +73,7 @@ def load_config() -> DocReaderConfig:
* 1024
)
grpc_port = _get_int(["DOCREADER_GRPC_PORT", "PORT"], 50051)
docx_max_pages = _get_int(["DOCREADER_DOCX_MAX_PAGES"], 100)
docx_max_pages = _get_int(["DOCREADER_DOCX_MAX_PAGES"], 0)
external_http_proxy = _get_str(
["DOCREADER_EXTERNAL_HTTP_PROXY", "EXTERNAL_HTTP_PROXY"], ""
+2
View File
@@ -97,6 +97,8 @@ class DocxParser(BaseParser):
"""
super().__init__(**kwargs)
self.max_pages = CONFIG.docx_max_pages if max_pages is None else max_pages
if self.max_pages <= 0:
self.max_pages = 100000 # no limit (matches Docx.__call__ default)
logger.info(f"DocxParser initialized with max_pages={self.max_pages}")
def parse_into_text(self, content: bytes) -> DocumentModel: