fix(platform): 汇总知识库问答与图表展示修复

This commit is contained in:
HTEWJ\26070045 authored and sophie committed 2026-08-07 10:07:00 +08:00
1 parent f615e56bb9
commit 87ea4ed8a9
41 files changed
+4569 -770

No files matched your search

+18
View File
@@ -243,6 +243,7 @@ def _normalize_path_for_match(p: Path | str) -> str:
_WORD_TIMEOUT_EXTS = {".doc", ".docx"}
_PDF_TIMEOUT_EXTS = {".pdf"}
# Excel/CSV are fast and in-process; skip spawn timeout wrapper (macOS/gevent safe).
_FAST_PATH_EXTS = {".xlsx", ".xls", ".csv", ".txt", ".md"}
@@ -257,6 +258,19 @@ def _parse_timeout_env(name: str, default: str = "0") -> int | None:
def _file_timeout_sec(file_path: Path | None = None) -> int | None:
"""
按源文件类型选择清洗子进程的最长运行时间。
图文 PDF 的 OCR、版面恢复和分段通常显著慢于 Office 文档;若直接复用全局
时限,大型手册会在内容尚未产出时被误杀。PDF 可用独立环境变量延长时限,
其他格式仍使用全局上限,避免异常任务无限占用 worker。
Args:
file_path: 待清洗源文件路径;仅使用其扩展名进行策略选择。
Returns:
正整数秒数表示启用子进程时限;None 表示该格式不使用 spawn 时限包装。
"""
suffix = str(getattr(file_path, "suffix", "") or "").lower()
if suffix in _FAST_PATH_EXTS:
return None
@@ -264,6 +278,10 @@ def _file_timeout_sec(file_path: Path | None = None) -> int | None:
specific = _parse_timeout_env("EDKB_WORD_FILE_TIMEOUT_SEC")
if specific:
return specific
if suffix in _PDF_TIMEOUT_EXTS:
specific = _parse_timeout_env("EDKB_PDF_FILE_TIMEOUT_SEC")
if specific:
return specific
return _parse_timeout_env("EDKB_FILE_TIMEOUT_SEC")