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

请问支持多文档吗

Open qinshuaibo opened this issue 1 year ago • 2 comments

功能描述 / Feature Description 用简洁明了的语言描述所需的功能 / Describe the desired feature in a clear and concise manner.

解决的问题 / Problem Solved 解释此功能如何解决现有问题或改进项目 / Explain how this feature solves existing problems or improves the project.

实现建议 / Implementation Suggestions 如果可能,请提供关于如何实现此功能的建议 / If possible, provide suggestions on how to implement this feature.

替代方案 / Alternative Solutions 描述您考虑过的替代方案 / Describe alternative solutions you have considered.

其他信息 / Additional Information 添加与功能请求相关的任何其他信息 / Add any other information related to the feature request.

qinshuaibo avatar Feb 21 '24 10:02 qinshuaibo

🤖

嗨,@qinshuaibo!很高兴再次看到你的提问。希望你最近一切都好!

是的,Langchain-Chatchat支持多文档功能。在我们的代码库中,有一个名为test_upload_docs的函数,它可以上传多个文件到知识库。这些文件包括"FAQ.MD", "README.MD"和"test.txt"。这表明Langchain-Chatchat可以处理和管理多个文档。

以下是相关的代码片段:

def test_upload_docs():
    files = list(test_files.values())

    print(f"\n上传知识文件")
    data = {"knowledge_base_name": kb, "override": True}
    data = api.upload_kb_docs(files, **data)
    pprint(data)
    assert data["code"] == 200
    assert len(data["data"]["failed_files"]) == 0

这段代码来自tests/api/test_kb_api_request.py

此外,根据我们的代码库,上传多个文档时并没有明确的限制或约束。但是,有几点需要考虑:

  1. upload_docs函数支持多文件上传,如参数files: List[UploadFile] = File(..., description="上传文件,支持多文件")所示。

  2. upload_docs函数中的override参数决定是否覆盖同名的现有文件。如果override设置为False(这是默认值),并且已经存在同名同大小的文件,那么新文件将不会被保存,同时会记录一条警告:文件 {filename} 已存在

  3. upload_docs函数还处理文件上传过程中的失败。如果文件上传失败,文件名和错误信息将被存储在failed_files字典中。

  4. upload_docs函数还支持上传文件的向量化,通过to_vector_store参数控制。如果设置为True,上传的文件将被向量化。

  5. upload_docs函数中的chunk_sizechunk_overlap参数分别控制知识库中单个文本段的最大长度和相邻文本段之间的重叠长度。

  6. upload_docs函数中的zh_title_enhance参数决定是否启用中文标题增强。

请注意,实际的限制或约束可能取决于服务器配置、网络条件和文件大小。

这些信息来自server/knowledge_base/kb_doc_api.py

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 21 '24 10:02 dosubot[bot]

请问当用户关闭界面后,之前上传的文档还会保存吗

qinshuaibo avatar Feb 21 '24 12:02 qinshuaibo

上传成功的当然还在,知识库的content文件夹里会留存一份

lurenyi4 avatar Feb 22 '24 07:02 lurenyi4