Langchain-Chatchat
Langchain-Chatchat copied to clipboard
[BUG] 添加知识库文件doc,docx文件失败
问题描述 / Problem Description 添加知识库文件doc,docx文件失败
复现问题的步骤 / Steps to Reproduce 添加doc,docx文件
预期的结果 / Expected Result 正常分割文件
实际结果 / Actual Result 文件正常上传未正常分割/读取
2024-02-27 22:32:20,629 - utils.py[line:298] - INFO: RapidOCRDocLoader used for C:\ai\Langchain-Chatchat\knowledge_base\test\content\jq1.doc
***fuckfuck55
RapidOCRDocLoader
C:\ai\Langchain-Chatchat\knowledge_base\test\content\jq1.doc
{}
***fuckfuck66
***fuckfuck1122
2024-02-27 22:32:21,007 - utils.py[line:394] - ERROR: PackageNotFoundError: 从文件 test/jq1.doc 加载文档时出错:Package not found at 'C:\ai\Langchain-Chatchat\knowledge_base\test\content\jq1.doc'
异常定位在utils.py的66打印下
def file2docs(self, refresh: bool = False):
print("***fuckfuck33")
if self.docs is None or refresh:
print("***fuckfuck44")
logger.info(f"{self.document_loader_name} used for {self.filepath}")
print("***fuckfuck55")
print(self.document_loader_name);
print(self.filepath);
print(self.loader_kwargs);
loader = get_loader(loader_name=self.document_loader_name,
file_path=self.filepath,
loader_kwargs=self.loader_kwargs)
print("***fuckfuck66")
self.docs = loader.load()--------------------------------------->出错
print("***fuckfuck77")
return self.docs
环境信息 / Environment Information
- langchain-ChatGLM 版本/commit 号:(例如:v2.0.1 或 commit 123456) / langchain-ChatGLM version/commit number: (e.g., v2.0.1 or commit 123456)
- 是否使用 Docker 部署(是/否):否
- 使用的模型(ChatGLM2-6B / Qwen-7B 等):ChatGLM3-6B
- 使用的 Embedding 模型(moka-ai/m3e-base 等):moka-ai/m3e-base / Embedding model used (moka-ai/m3e-base, etc.): moka-ai/m3e-base
- 使用的向量库类型 (faiss / milvus / pg_vector 等): faiss
- 操作系统及版本 / win11,anaconda
- Python 版本 / 3.11
- 其他相关环境信息 / Other relevant environment information:
附加信息 / Additional Information 添加与问题相关的任何其他信息 / Add any other information related to the issue.
有大神可以给个解决方案吗
🤖
嘿,@toasun!很高兴再次看到你提出问题。希望你一切都好!
根据您提供的信息,我发现了几个可能的问题和解决方案。
首先,从错误日志来看,问题可能出在 RapidOCRDocLoader
这个类上,它在尝试加载您的 .doc
文件时出错。这可能是因为这个类没有正确处理 .doc
文件的格式。您可以尝试将 .doc
文件转换为 .docx
或 PDF 文件,然后再试一次。
其次,我在 Langchain-Chatchat 的问题跟踪中找到了几个类似的问题,可能对您有所帮助:
-
同时上传多个doc文件时出错:这个问题的建议解决方案是检查问题是否与在多线程环境中同时调用系统安装的程序处理
.doc
文档有关。建议尝试将.doc
文件转换为.docx
或 PDF 作为解决方案。 -
[BUG] 建立向量库时,可以解析.docx文档,但是无法解析.doc文档:这个问题的解决方案是修复
server/knowledge_base\utils.py
行106 的笔误,将 "UnstructuredWordDocumentLoader": ['.docx', 'doc'], 改为 "UnstructuredWordDocumentLoader": ['.docx', '.doc']。 -
自定义知识库 上传、删除等报错:这个问题的解决方案是更新项目代码和依赖项(特别是 langchain/fschat),然后再试一次。
希望这些信息对您有所帮助。如果问题仍然存在,或者您有其他问题,欢迎随时向我提问。
Sources
- 同时上传多个doc文件时出错
- [BUG] 建立向量库时,可以解析.docx文档,但是无法解析.doc文档
- 自定义知识库 上传、删除等报错
- server/knowledge_base/kb_doc_api.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
这个问题我也遇到了,doc解析失败,docx成功,排查了一下,PackageNotFoundError
应该指的是soffice依赖库没有安装造成的,运行 apt-get install libreoffice-writer
应该能解决问题,由于我用的是WSL2,没有继续尝试,遇到问题的可以试一试。
这个问题我也遇到了,doc解析失败,docx成功,排查了一下,
PackageNotFoundError
应该指的是soffice依赖库没有安装造成的,运行apt-get install libreoffice-writer
应该能解决问题,由于我用的是WSL2,没有继续尝试,遇到问题的可以试一试。
我也安装了libreoffice,不知道是什么原因,就是读doc报错,难道我是win11直接在anaconda上跑的? 我看到项目依赖的库是python-docx,但是我python-docx都是安装好的,没道理一个python项目读写doc文件需要用到跨系统的其他工具…… 再等一个大神解我心头之惑
🤖
It seems like this issue requires a deeper look, @imClumsyPanda could you please lend your expertise?
和你一样,win11直接运行anaconda,上传都没问题,就是不能向量doc,向量docx没问题。
您好,问题解决了吗
doc应该是langchian的问题,尝试回滚到之前的lc,不然也没办法的,这部分用的是lc
doc应该是langchian的问题,尝试回滚到之前的lc,不然也没办法的,这部分用的是lc
一直想问lc是啥
doc应该是langchian的问题,尝试回滚到之前的lc,不然也没办法的,这部分用的是lc
一直想问lc是啥
langchian的缩写。。
doc应该是langchian的问题,尝试回滚到之前的lc,不然也没办法的,这部分用的是lc
你好,这里建议的lc版本是多少呢?
您好,lc是他吗