dify官方网站的在线案例:https://cloud.dify.ai/app,chat-messages接口是有传parent_message_id参数,但是webapp-conversation仓库的案例没有追加parent_message_id参数,导致多轮会话上下文丢失 #82

Closed
opened 2026-02-16 10:16:03 -05:00 by yindo · 0 comments
Owner

Originally created by @fengyun2 on GitHub (May 22, 2025).

dify官方网站的在线案例:https://cloud.dify.ai/app

/v1/chat-messages接口是有传parent_message_id参数,但是webapp-conversation仓库的案例没有追加parent_message_id参数,导致多轮会话上下文丢失。

日志查询接口:https://cloud.dify.ai/console/api/apps/APP_ID/chat-messages?conversation_id=CONVERSATION_ID&limit=10

通过nextjs接口调用方案

实际效果:

接口:https://api.dify.ai/v1/chat-messages
第一轮请求参数:
{'inputs': {}, 'query': '你好', 'response_mode': 'blocking', 'user': 'user_周星星007'}
第二轮请求参数:
{'inputs': {}, 'query': '今天天气怎么样', 'response_mode': 'blocking', 'user': 'user_周星星007', 'conversation_id': '9bec66d4-0117-4048-b1a9-6c94f5c82a5d', 'parent_message_id': '379d3964-4c62-48ec-bc60-102c75b61adb'}
第三轮请求参数:
{'inputs': {}, 'query': '今天适宜露营吗', 'response_mode': 'blocking', 'user': 'user_周星星007', 'conversation_id': '9bec66d4-0117-4048-b1a9-6c94f5c82a5d', 'parent_message_id': 'c295269d-d7fb-415d-a17c-8c5f8bcd14ec'}
三轮日志结果如下:

Image

通过官网内置网址运行方案(https://cloud.dify.ai/app)

期望效果:

接口:https://udify.app/api/chat-messages

第一轮请求参数:

{
    "response_mode": "streaming",
    "conversation_id": "",
    "files": [],
    "query": "你好",
    "inputs": {},
    "parent_message_id": null
}

第二轮请求参数:

{
    "response_mode": "streaming",
    "conversation_id": "3805bb3e-a5b4-4be0-93a0-65b3f748a024",
    "files": [],
    "query": "今天天气怎么样",
    "inputs": {},
    "parent_message_id": "063f1025-16d5-4dad-b4f3-c46b09528b2f"
}

第三轮请求参数:
{ "response_mode": "streaming", "conversation_id": "3805bb3e-a5b4-4be0-93a0-65b3f748a024", "files": [], "query": "今天适宜露营吗", "inputs": {}, "parent_message_id": "ebd902ee-c18f-4af1-961e-5636f39ff100" }

三轮日志结果如下:

Image

期望效果

通过nextjs接口调用方案时,dify后端接口也能接收 parent_message_id 参数,且在 [发送对话消息]: /v1/chat-messages 接口、/console/api/apps/APP_ID/chat-messages 接口以及 [获取会话历史消息]:/v1/messages)接口也能返回正确的 parent_message_id。(非00000000-0000-0000-0000-000000000000`或null)。

Originally created by @fengyun2 on GitHub (May 22, 2025). ### dify官方网站的在线案例:https://cloud.dify.ai/app, /v1/chat-messages接口是有传parent_message_id参数,但是webapp-conversation仓库的案例没有追加parent_message_id参数,导致多轮会话上下文丢失。 日志查询接口:`https://cloud.dify.ai/console/api/apps/APP_ID/chat-messages?conversation_id=CONVERSATION_ID&limit=10` #### 通过nextjs接口调用方案 **实际效果:** 接口:`https://api.dify.ai/v1/chat-messages` 第一轮请求参数: `{'inputs': {}, 'query': '你好', 'response_mode': 'blocking', 'user': 'user_周星星007'}` 第二轮请求参数: `{'inputs': {}, 'query': '今天天气怎么样', 'response_mode': 'blocking', 'user': 'user_周星星007', 'conversation_id': '9bec66d4-0117-4048-b1a9-6c94f5c82a5d', 'parent_message_id': '379d3964-4c62-48ec-bc60-102c75b61adb'}` 第三轮请求参数: `{'inputs': {}, 'query': '今天适宜露营吗', 'response_mode': 'blocking', 'user': 'user_周星星007', 'conversation_id': '9bec66d4-0117-4048-b1a9-6c94f5c82a5d', 'parent_message_id': 'c295269d-d7fb-415d-a17c-8c5f8bcd14ec'}` 三轮日志结果如下: ![Image](https://github.com/user-attachments/assets/3b70a44e-a1d2-427f-bb63-3dedc5d38dd4) #### 通过官网内置网址运行方案(https://cloud.dify.ai/app) **期望效果:** 接口:`https://udify.app/api/chat-messages` 第一轮请求参数: ``` { "response_mode": "streaming", "conversation_id": "", "files": [], "query": "你好", "inputs": {}, "parent_message_id": null } ``` 第二轮请求参数: ``` { "response_mode": "streaming", "conversation_id": "3805bb3e-a5b4-4be0-93a0-65b3f748a024", "files": [], "query": "今天天气怎么样", "inputs": {}, "parent_message_id": "063f1025-16d5-4dad-b4f3-c46b09528b2f" } ``` 第三轮请求参数: `{ "response_mode": "streaming", "conversation_id": "3805bb3e-a5b4-4be0-93a0-65b3f748a024", "files": [], "query": "今天适宜露营吗", "inputs": {}, "parent_message_id": "ebd902ee-c18f-4af1-961e-5636f39ff100" }` 三轮日志结果如下: ![Image](https://github.com/user-attachments/assets/2890c25f-1cd5-41d0-a225-89e39487a97a) ### 期望效果 通过**nextjs接口调用方案**时,dify后端接口也能接收 `parent_message_id` 参数,且在 [发送对话消息]: `/v1/chat-messages` 接口、`/console/api/apps/APP_ID/chat-messages` 接口以及 [获取会话历史消息]:`/v1/messages)接口也能返回正确的 `parent_message_id`。(非`00000000-0000-0000-0000-000000000000`或null)。
yindo closed this issue 2026-02-16 10:16:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/webapp-conversation#82