Closed guogeer closed 1 week ago
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:
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.
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.
Self Checks
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
✔️ Expected Behavior
output annotation or moderation result
❌ Actual Behavior
empty