Closed QuintinShaw closed 3 months ago
Hello @QuintinShaw! I'm here to assist you with bug fixes, answer questions, and guide you on becoming a contributor. If you need any help, feel free to reach out!
The issue you're experiencing with adding annotations for conversations with more than 4 replies in Chatbot Chatflow BETA mode on Dify version 0.6.15 is likely due to the annotation_reply
feature being disabled in the configuration. This feature needs to be enabled to allow annotations for conversations with more than 4 replies.
Here's the relevant configuration setting:
"annotation_reply": {
"enabled": false
}
To resolve this issue, you need to enable the annotation_reply
feature in the configuration [1].
Additionally, the missing Conversation ID in the request URL for conversations with more than 4 replies could be due to how the Conversation ID is being managed. The Conversation ID should be retrieved and passed correctly in the URL for the annotation request. Ensure that the conversation_id
is being correctly maintained and passed in the request for continuing an existing dialogue [2][3].
If the issue persists, it might be related to recent changes in the repository, such as the migration script e1901f623fd0_add_annotation_reply.py
, which includes modifications to the message_annotations
table. These changes could potentially affect the functionality related to annotations in conversations [4].
Check these configurations and recent changes to ensure that the annotation_reply
feature is enabled and the Conversation ID is correctly managed.
To continue talking to Dosu, mention @dosu.
Thank you for your response. However, I'd like to clarify that the annotation_reply feature is already enabled in my configuration. This issue occurs on both cloud and self-hosted versions, using Chrome version 126.0.6478.183 and Safari 17.1.2 (19616.2.9.11.12).
The core problem remains: the Conversation ID is missing from the URL when trying to add annotations to conversations with more than 4 replies.
Is there any other information I can provide to help diagnose this issue? I'm happy to assist with further testing or provide access to a test environment if needed.
To resolve the issue of the missing conversation_id
in the request URL for conversations with more than 4 replies, ensure that the conversation_id
is correctly passed in your API request. Here is an example of how to include the conversation_id
in your request:
curl --location --request POST 'https://api.dify.ai/v1/chat-messages' \
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"inputs": {},
"query": "eh",
"response_mode": "streaming",
"conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
"user": "abc-123"
}'
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": {},
"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())
Ensure that the conversation_id
is correctly included in the request payload. According to the Dify documentation, the conversation_id
is an optional field but must be included if you want to continue a conversation based on previous chat history [1][2].
Additionally, recent changes in the Dify codebase might have affected the handling of conversation_id
in the "Add annotation" functionality. Specifically, in the migration script e1901f623fd0_add_annotation_reply.py
, the conversation_id
column in the message_annotations
table was altered to be nullable [3].
If the issue persists, you may want to check the specific part of the Dify codebase responsible for constructing the request URL for adding annotations. The ChatClient
class within the create_chat_message
method constructs the request URL and includes the conversation_id
in the JSON payload if it is provided [4][5].
Here is the relevant code snippet:
class ChatClient(DifyClient):
def create_chat_message(self, inputs, query, user, response_mode="blocking", conversation_id=None, files=None):
data = {
"inputs": inputs,
"query": query,
"user": user,
"response_mode": response_mode,
"files": files
}
if conversation_id:
data["conversation_id"] = conversation_id
return self._send_request("POST", "/chat-messages", data,
stream=True if response_mode == "streaming" else False)
This method ensures that the conversation_id
is included as a field in the JSON payload if it is not None
. The request is then sent to the /chat-messages
endpoint.
To continue talking to Dosu, mention @dosu.
Self Checks
Dify version
0.6.15
Cloud or Self Hosted
Cloud
Steps to reproduce
Cloud or Self Hosted: Both (Cloud and Self Hosted Docker deployment)
Steps to reproduce:
Create a conversation with more than 4 replies in Chatbot Chatflow BETA mode. Go to Logs & Ann. > Logs > Conversation for that specific chat. Try to add an annotation. Observe that the "Add annotation" functionality doesn't work. Check the network requests in the browser's developer tools to confirm the missing Conversation ID in the URL.
Comment: In the Chatbot Chatflow BETA mode, under Logs & Ann. > Logs > Conversation, it's impossible to add annotations once the conversation exceeds 4 replies (4 user messages and 4 system responses, 8 messages in total).
Upon investigating with the browser's developer tools (F12), I noticed that:
For conversations with 3 or fewer replies, the "Add annotation" button correctly sends a request to: https://cloud.dify.ai/console/api/apps/d4d02a0f-a984-4913-9b99-923eb61258e6/annotations
For conversations with more than 4 replies, the request URL changes to: https://cloud.dify.ai/console/api/apps//annotations
The Conversation ID is missing from the URL in the latter case, which appears to be causing the issue.
✔️ Expected Behavior
The ability to add annotations should work for all conversations, regardless of the number of replies.
❌ Actual Behavior
Unable to add annotations for conversations with more than 4 replies due to a missing Conversation ID in the request URL.