当前位置:   article > 正文

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

langchain docx

按照截止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系统。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/860590
推荐阅读
相关标签
  

闽ICP备14008679号