Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于QA(问答)类型的数据,再上传知识库前使用什么数据格式组织问题和答案呢? #3164

Closed
cwqJim2023 opened this issue Mar 4, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@cwqJim2023
Copy link

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

  1. 车辆外观如何?
    这辆车的外观比较有亲和力,大众接受度较高

解决的问题 / 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.

@cwqJim2023 cwqJim2023 added the enhancement New feature or request label Mar 4, 2024
Copy link

dosubot bot commented Mar 4, 2024

嘿,@cwqJim2023,我们又见面了!希望你最近过得不错。

根据您提供的上下文,应使用JSON数据格式来组织QA类型数据的问题和答案,然后上传到知识库。这个结论是基于以下几点证据:

  1. 在函数签名中使用pydanticJson,例如在upload_docs函数中,docs: Json = Form({}, description="自定义的docs,需要转为json字符串", examples=[{"test.txt": [Document(page_content="custom doc")]}])表明文档(包括问题和答案)的预期格式是JSON。

  2. 在多个地方使用json.dumps方法将对象序列化为JSON格式的str,例如在recreate_vector_store函数中。这进一步支持使用JSON作为组织和处理QA类型数据的数据格式。

  3. 处理的数据的结构,特别是在update_docsupload_docs函数中,文档被表示为字典,键和值都可以轻松地表示为JSON格式。例如,docs: Json = Body({}, description="自定义的docs,需要转为json字符串", examples=[{"test.txt": [Document(page_content="custom doc")]}])表明文档(可能包括QA对)预期为JSON兼容格式。

因此,在这种情况下,推荐使用JSON数据格式来组织问题和答案,然后上传到知识库。

关于JSON格式的具体结构,Langchain-Chatchat代码库中用于组织问题和答案的JSON格式的具体结构如下:

{
  "text": "<answer or token>",
  "message_id": "<message_id>"
}

这个结构用于组织发送回客户端的响应。text字段包含模型生成的答案或令牌,message_id字段包含接收到查询时添加到数据库的消息的ID。这个JSON结构在chat_iterator异步函数中的流式和非流式响应场景中都有使用。

参考源码:

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.

@zRzRzRzRzRzRzR
Copy link
Collaborator

csv或者markdown都行,csv就是q一列a一列

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants