-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DifY API is not bringing the conversation/session history #8910
Comments
Hello, @edrizo! I'm here to help you with any bugs, questions, or contributions you have regarding DifY. Let's tackle this issue together! I found a similar open issue that might be relevant to your problem: Custom API Chatbot with nodejs no history of the conversation Included. The suggested solution involves ensuring that the
Here is an example in JavaScript: const axios = require('axios');
const API_URL = 'https://api.dify.ai/v1/chat-messages';
const API_KEY = 'YOUR_SECRET_KEY';
let conversationId = '';
async function sendMessage(query) {
try {
const response = await axios.post(API_URL, {
inputs: {},
query: query,
response_mode: 'streaming',
conversation_id: conversationId,
user: 'abc-123'
}, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
// Update conversationId with the one from the response
if (response.data.conversation_id) {
conversationId = response.data.conversation_id;
}
console.log(response.data);
} catch (error) {
console.error('Error sending message:', error);
}
}
// Example usage
sendMessage('Hello, how are you?').then(() => {
sendMessage('Can you tell me more about that?');
}); In this example:
Make sure to replace Additionally, the Dify API returns specific error codes or messages when the For securely managing and using API keys, it is recommended to call them through the backend rather than exposing them in plaintext within frontend code or requests. This helps prevent your application from being abused or attacked [4][5][6][7]. |
"Retrieve the conversation_id after the initial chat request. I'm doing this. The conversation_id is corret. But still have the issue. |
When using the Dify API, if the
If all these conditions are met and the issue persists, it might be necessary to review the specific implementation details or consult the Dify documentation for any additional configuration requirements. |
|
To ensure the conversation history is maintained using the Dify API, follow these steps:
Here is a detailed example: Initial CallMake the first call to generate a {
"inputs": {},
"query": "Hi",
"response_mode": "blocking",
"user": "abc-123"
} The response will include a {
"event": "message",
"task_id": "task-123",
"id": "id-123",
"message_id": "msg-123",
"conversation_id": "conv-123",
"mode": "blocking",
"answer": "Hello! How can I help you?",
"metadata": {
"created_at": "2024-09-30T12:34:56Z"
}
} Subsequent CallsUse the {
"inputs": {},
"query": "Can you tell me more about that?",
"response_mode": "blocking",
"conversation_id": "conv-123",
"user": "abc-123"
} Key Points
If the issue persists despite following these steps, ensure that the |
I did it. And still remains the issue. |
I have the same issue, not happening in the previous version. whats has changed? |
Which version? I'm using cloud version. Not self hosted. Weird. |
yes I mean the previous cloud version doesn't have this issue. |
I'm having this problem too... |
confirm its only in cloud version. self-host version working fine even with the latest 0.8.3 |
I also confirmed this problem with the cloud version. There is a difference in the |
Did you self hosted it? And the issue is not happening? |
Also having the same problem, I'll buy a server so I self-host Dify due to this problem. |
This is it! After upgrading the Docker version from 0.8.3 to 0.9.0, I encountered the same issue. Is there any way to roll back to version 0.8.3?😭 |
I tested the cloud version about 2 hours ago and found that a problem had occurred, and when I checked just now, the history was displayed normally. I have experienced the problem going away after a certain amount of time has passed. Either way, the history where the problem occurred has a |
Complicated. What to do now? |
I don't know how to do it. |
Alright, I got it. Then,
At this point, just hope that the developers or other users will also notice the issue. Is using Dify through the API really that uncommon? The missing conversation history should be pretty obvious... (Oh, I’m sorry I didn’t notice that you’re using the cloud version. |
I use Dify with N8N and Z-API and the only solution I found for this issue is to pay for Redis and save the information inside their server (or something like that), which is not optimal for something that is a bug, hopefully they will fix it. |
See #8749, this is a follow-up pr to display the regenerated things. |
Mine also have they also should be 0.8.3? |
As for the others, like the sandbox and such, I didn’t make any changes. Keeping them as they are should be fine. |
|
Running migrations |
@xd845217xd this is the error when trying to use 0.8.3 |
Anyone? |
I am able to reproduce this with a chatflow in both streaming and blocking mode. Dify Cloud v 0.8.3. @takatost that's a critical issue, it's breaking a lot of applications right now. |
@crazywoola That's another issue. Using the Advanced Chat App API results in conversation history being lost and LLM calls do not contain the history. I assume the breaking change coming with the regeneration feature broke the Advanced Chat App API. |
Same problem here!!!! |
@edrizo Once you upgrade from 0.8.3 to 0.9.0, the database contents will be upgraded for 0.9.0, so even if you revert only the Docker image to 0.8.3, it will not start. You will also need to write back the contents of the |
I hadn't installed it on the VPS yet. When I did it, the "latest" version is 0.9.1, and the same bug also happened. The devs are already working on it. I'll wait for the repair! Thanks a lot @fujita-h |
Self Checks
Dify version
0.8.3
Cloud or Self Hosted
Cloud
Steps to reproduce
When we click view through DiFy itself, the conversation is complete. The session is being considered in the conversation.
However, when using the API call, this does not happen.
✔️ Expected Behavior
API calls working with the conversation session being respected.
❌ Actual Behavior
All previous conversations do not appear in the session history.
The text was updated successfully, but these errors were encountered: