OpenViking
OpenViking copied to clipboard
[Bug]: docx 等基于 ZIP 容器的文件被错误地当作 ZIP 解析,未使用专用解析器
Bug Description
通过 add_resource() 添加 .docx 、 .pptx 、 .xlsx 、 .epub 等文件时,OpenViking 将其视为普通 ZIP 压缩包解压,而不是使用已注册的专用解析器(WordParser、PowerPointParser、ExcelParser、EPubParser)
根本原因
openviking/utils/media_processor.py 中 _process_file() 先检查 zipfile.is_zipfile() ,再检查是否有专用解析器:
async def _process_file(self, file_path:
Path, ...):
if zipfile.is_zipfile(file_path): #
docx 等在此匹配
zipf.extractall(temp_dir)
return await self.
_process_directory(...) # 错误路径
return await parse(...) # 专用解析器在这
里,但未到达
Steps to Reproduce
import openviking as ov
client = ov.SyncOpenViking(path="./test_store")
client.add_resource("./test.docx", wait=True)
# 检查结果 - 会看到 XML 文件而不是文档内容
Expected Behavior
.docx 等类型文件应该由 专用的WordParser 等解析,该解析器会:
- 使用 python-docx 提取文本内容
- 转换为 Markdown 格式
- 创建正确的语义分块以便检索
Actual Behavior
.docx 等类型文件被当作普通 ZIP 压缩包处理:
- 解压到临时目录
- 作为目录处理其中的 XML 文件
- 生成无用的内容(如 [Content_Types].xml 、 word/document.xml 等 XML 片段)
Minimal Reproducible Example
Error Logs
OpenViking Version
0.2.1
Python Version
3.13.12
Operating System
macOS
Model Backend
None
Additional Context
No response