api /v1/chat-messages match annotation or moderation on blocking in service api of chat flow, but answer is empty #4561

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

Originally created by @guogeer on GitHub (Jul 11, 2024).

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).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.13

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

api /v1/chat-messages match annotation or moderation on blocking in service api of chat flow, but answer is empty

image
20240711-193706

✔️ Expected Behavior

output annotation or moderation result

Actual Behavior

empty

Originally created by @guogeer on GitHub (Jul 11, 2024). ### 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] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.13 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce api /v1/chat-messages match annotation or moderation on blocking in service api of chat flow, but answer is empty ![image](https://github.com/langgenius/dify/assets/5010851/faceed8d-ab85-4774-9e57-0486661b3e2c) ![20240711-193706](https://github.com/langgenius/dify/assets/5010851/5dbb4757-8a2d-4d77-8cf8-15d298454a86) ### ✔️ Expected Behavior output annotation or moderation result ### ❌ Actual Behavior empty
yindo added the 🐞 bug label 2026-02-21 18:07:02 -05:00
yindo closed this issue 2026-02-21 18:07:02 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 11, 2024):

The response might be empty because the inputs field in your request is empty. Ensure that the inputs field contains relevant data. Here is an example of a correctly formatted request for the /v1/chat-messages endpoint:

import requests
import json

url = 'https://api.dify.ai/v1/chat-messages'
headers = {
    'Authorization': 'Bearer ENTER-YOUR-SECRET-KEY',
    'Content-Type': 'application/json',
}
data = {
    "inputs": {"text": "Hello, how are you?"},  # Ensure this field is populated
    "query": "eh",
    "response_mode": "streaming",
    "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
    "user": "abc-123"
}

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.json())

Make sure the inputs field is not empty and contains the necessary data for the API to process.

Additionally, ensure that the moderation and annotation processes are correctly configured. The AgentChatAppRunner class in Dify's codebase handles these processes. If there are issues with moderation or annotation, the response might be empty. Check the following:

  1. Moderation: Ensure that the moderation process does not raise any exceptions. If a ModerationException is raised, it will directly output the exception message and return. You can extend custom content moderation rules at the code level in a private deployment of Dify. For example, you can create a custom moderation class like CloudServiceModeration to handle specific business logic for moderation.

  2. Annotation: Verify that the annotation reply is correctly processed. If an annotation reply is found, it will be published and returned.

Review the AgentChatAppRunner class to ensure that all necessary configurations and processes are correctly set up. For more detailed guidance on extending and debugging custom moderation rules, refer to the Dify documentation on Sensitive Content Moderation [1][2][3][4].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 11, 2024): <!-- Answer --> The response might be empty because the `inputs` field in your request is empty. Ensure that the `inputs` field contains relevant data. Here is an example of a correctly formatted request for the `/v1/chat-messages` endpoint: ```python import requests import json url = 'https://api.dify.ai/v1/chat-messages' headers = { 'Authorization': 'Bearer ENTER-YOUR-SECRET-KEY', 'Content-Type': 'application/json', } data = { "inputs": {"text": "Hello, how are you?"}, # Ensure this field is populated "query": "eh", "response_mode": "streaming", "conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276", "user": "abc-123" } response = requests.post(url, headers=headers, data=json.dumps(data)) print(response.json()) ``` Make sure the `inputs` field is not empty and contains the necessary data for the API to process. Additionally, ensure that the moderation and annotation processes are correctly configured. The `AgentChatAppRunner` class in Dify's codebase handles these processes. If there are issues with moderation or annotation, the response might be empty. Check the following: 1. **Moderation**: Ensure that the moderation process does not raise any exceptions. If a `ModerationException` is raised, it will directly output the exception message and return. You can extend custom content moderation rules at the code level in a private deployment of Dify. For example, you can create a custom moderation class like `CloudServiceModeration` to handle specific business logic for moderation. 2. **Annotation**: Verify that the annotation reply is correctly processed. If an annotation reply is found, it will be published and returned. Review the `AgentChatAppRunner` class to ensure that all necessary configurations and processes are correctly set up. For more detailed guidance on extending and debugging custom moderation rules, refer to the Dify documentation on [Sensitive Content Moderation](https://docs.dify.ai/en/guides/extension/code-based-extension/moderation) <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/application-publishing/developing-with-apis.md)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/app/apps/chat/app_runner.py)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/extension/code-based-extension/moderation.md)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/core/app/apps/agent_chat/app_runner.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4561