请问通过API 访问/chat-messages 接口如何增加上下文知识库和前置一些数据信息RAG #8322

Closed
opened 2026-02-21 18:25:04 -05:00 by yindo · 1 comment
Owner

Originally created by @284658474 on GitHub (Feb 17, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Cloud

Steps to reproduce

请问通过API 访问/chat-messages 接口如何增加上下文知识库和前置一些数据信息RAG,在文档中只看到了访问对话,没有说怎么增加上下文知识库参数

{"inputs":{"maxTokens":0,"temperature":0.0},"query":"报销金额","response_mode":"streaming","conversation_id":"","user":"app_id","files":[{"type":"knowledge_base","transfer_method":"file_id","file_id":"af898965-7372-4553-a4d3-183075c63f0b"}]}

✔️ Expected Behavior

Image

Actual Behavior

No response

Originally created by @284658474 on GitHub (Feb 17, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15.3 ### Cloud or Self Hosted Cloud ### Steps to reproduce 请问通过API 访问/chat-messages 接口如何增加上下文知识库和前置一些数据信息RAG,在文档中只看到了访问对话,没有说怎么增加上下文知识库参数 {"inputs":{"maxTokens":0,"temperature":0.0},"query":"报销金额","response_mode":"streaming","conversation_id":"","user":"app_id","files":[{"type":"knowledge_base","transfer_method":"file_id","file_id":"af898965-7372-4553-a4d3-183075c63f0b"}]} ### ✔️ Expected Behavior ![Image](https://github.com/user-attachments/assets/a106ec3f-d3df-4cf6-b9fa-9e179d711053) ### ❌ Actual Behavior _No response_
yindo added the 🙋‍♂️ question👻 feat:rag labels 2026-02-21 18:25:04 -05:00
yindo closed this issue 2026-02-21 18:25:04 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 17, 2025):

Hello @284658474! 👋 I'm here to help you with any bugs, questions, or becoming a contributor. Let's squash those bugs together!

I found a similar discussion that might be relevant to your question: API 扩展能从页面传入自定义信息, which is currently unsolved [1].

Regarding your question about adding context knowledge base and RAG (Retrieval-Augmented Generation) data to the /chat-messages API, I couldn't find specific information in the available documentation. However, the inputs parameter in the API request allows you to enter various variable values defined by the app. This parameter contains key/value pairs for each variable, and if the variable is of file type, you should specify an object with the keys described in the files parameter [2][3][4].

For including additional data, the files parameter can be used to specify an array of file objects, each containing properties like type, transfer_method, and url [5].

If you need more detailed guidance on integrating RAG or context knowledge base, you might want to explore the discussions or documentation further, as the specific integration details were not found in the current sources.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 17, 2025): <!-- Greeting --> Hello @284658474! 👋 I'm here to help you with any bugs, questions, or becoming a contributor. Let's squash those bugs together! <!-- Answer --> I found a similar discussion that might be relevant to your question: [API 扩展能从页面传入自定义信息](https://github.com/langgenius/dify/discussions/3571), which is currently unsolved <sup>[[1]](https://github.com/langgenius/dify/discussions/3571)</sup>. Regarding your question about adding context knowledge base and RAG (Retrieval-Augmented Generation) data to the `/chat-messages` API, I couldn't find specific information in the available documentation. However, the `inputs` parameter in the API request allows you to enter various variable values defined by the app. This parameter contains key/value pairs for each variable, and if the variable is of file type, you should specify an object with the keys described in the `files` parameter <sup>[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_chat.en.mdx)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.en.mdx)</sup><sup>[[4]](https://github.com/langgenius/dify-docs/blob/main/en/guides/application-publishing/developing-with-apis.md)</sup>. For including additional data, the `files` parameter can be used to specify an array of file objects, each containing properties like `type`, `transfer_method`, and `url` <sup>[[5]](https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template_advanced_chat.zh.mdx)</sup>. If you need more detailed guidance on integrating RAG or context knowledge base, you might want to explore the discussions or documentation further, as the specific integration details were not found in the current sources. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e22435e9-08ac-46e9-bb5e-d46923b61fdd?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8322