关于langchain-chatchat中搭建本地知识向量库时doc,docx,ppt,pptx在文件处理时报错问题解决方案

按照截止2024年3月份的langchain-chatchat版本在本地完成部署后,在做本地知识库搭建时会出现如下问题:

一、不支持doc、docx、ppt、pptx格式的文件,会报错,如下图:

主要原因为RapidOCRDocLoader不支持处理doc文件,这个工具是用来处理PDF文件的,应该是原脚本有问题。

找到对应的脚本utils.py,路径:langchain-chatchat/server/knowledge_base

打开脚本将以下两行注释掉(这两行代码有错误,且多余):

# RapidOCRDocLoader": ['.docx', '.doc']

# RapidOCRPPTLoader": ['.ppt', '.pptx', ]

关闭webui和命令行终端,然后重启,在进行doc文件处理会提示如下错误:

024-04-03 20:06:16,182 - faiss_cache.py[line:92] - INFO: loading vector store in 'test1/vector_store/bge-large-zh-v1.5' from disk. Batches: 100%|███████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 9.32it/s] 2024-04-03 20:06:16,310 - utils.py[line:295] - INFO: UnstructuredWordDocumentLoader used for E:\chatchat\langchain-chatchat\knowledge_base\test1\content\ldm.doc 2024-04-03 20:06:18,105 - utils.py[line:377] - ERROR: FileNotFoundError: 从文件 test1/ldm.doc 加载文档时出错:soffice command was not found. Please install libreoffice on your system and try again. - Install instructions: https://www.libreoffice.org/get-help/install-howto/ - Mac: https://formulae.brew.sh/cask/libreoffice - Debian: https://wiki.debian.org/LibreOffice

此时说明我们的系统没有安装LibreOffice,UnstructuredWordDocumentLoader工具需要用到LibreOffice中的soffice工具。

注意conda中不能直接安装LibreOffice,需要到https://www.libreoffice.org/get-help/install-howto/网站下载windos版本,我选的是最新版本,然后下载安装到系统默认目录下面,然后添加环境变量,在资源浏览器中的此电脑上点右键选择属性/系统/高级系统设置/环境变量/系统变量/path,点编辑,添加LibreOffice路径,一般是C:\Program Files\LibreOffice\program。如下图:

然后重启系统,在进行doc,docx,ppt,pptx文档分割处理就成功。

注:我的langchain-chat是在conda中进行部署,win11系统。

  • 9
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值