Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

[BUG] 往知识库添加文件后再次init_database.py后,报错无法使用,无法还原

Open Hiroshi230 opened this issue 1 year ago • 4 comments

原先已经跑通代码(正常使用),随后往知识库添加了自己的文件后,再次运行进行init_database.py,显示报错,报错如下,整个源码目前无法运行(已经尝试替换代码)无法解决。

Hiroshi230 avatar Feb 22 '24 02:02 Hiroshi230

🤖

你好,@Hiroshi230!我是Dosu,一个可以帮助你解决bug、回答问题,并成为贡献者的机器人。我在这里帮助你,同时等待人类维护者的回应。我会立即查看你的问题,并尽快给你一个完整的回答。

dosubot[bot] avatar Feb 22 '24 02:02 dosubot[bot]

8bddad70c1537b0a921fbe07507ade8

Hiroshi230 avatar Feb 22 '24 02:02 Hiroshi230

🤖

I'm sorry, but I'm unable to view the image you've shared. However, based on the context you've provided, it seems like you're encountering an error after adding your own files to the knowledge base and running init_database.py again.

There are a few potential solutions to this issue based on similar issues that have been solved in the Langchain-Chatchat repository:

  1. Ensure that the OpenAI API key is correctly set in the model_config.py.example file. Specifically, replace the empty string in the "api_key" field with the actual OpenAI API key for the "openai-api" model, and replace "your OPENAI_API_KEY" with the actual OpenAI API key for the "text-embedding-ada-002" model. It is also advised to keep the API key confidential and use environment variables or secure methods to store and use it. If the issue persists after following these steps, further information might be needed, such as whether environment variables have been set elsewhere or if the API key is used in other parts of the code. You can refer to this issue for more details.

  2. Modify the __repr__ method to handle encoding errors. This involves wrapping the return statement in a try-except block to catch UnicodeEncodeError and return a simple error message instead. This will prevent the error from stopping the program but will not provide the full string representation of the object if it contains characters that cannot be encoded in UTF-8. You can refer to this issue for more details.

  3. Ensure that all files, especially the knowledge base that needs to be initialized, are in UTF-8 format. This comment suggests that the issue may be related to encoding problems. You can refer to this issue for more details.

If these solutions do not resolve your issue, could you please provide more details about the error you're encountering? Specifically, the error message and the steps you took before encountering the error would be very helpful.

Sources

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.

dosubot[bot] avatar Feb 22 '24 02:02 dosubot[bot]

init 那个要配合 -r 然后重新初始化,出现这个问题大概率是你模型有点问题或者你的环境配置错误,我在linux没有出现类似问题

zRzRzRzRzRzRzR avatar Feb 26 '24 01:02 zRzRzRzRzRzRzR

这个问题已经被标记为 stale ,因为它已经超过 30 天没有任何活动。

github-actions[bot] avatar Mar 27 '24 21:03 github-actions[bot]