-
Notifications
You must be signed in to change notification settings - Fork 9k
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
The stop response api is ineffective for "chat assistant" applications but works for "ChatFlow-type" applications. #13035
Comments
Hi @dht-hedaihua! 👋 I'm here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together! The issue you're experiencing with the For the
If these conditions are met and the issue persists, it might be necessary to investigate further into the specific implementation of the "chat assistant" application to identify any differences in event handling or lifecycle management that could affect the API's behavior. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
1. Could you share your API implementation code for both cases? import 'dart:convert';
import 'package:ai_student_qa_frontend/common/http/dify_dio_client.dart';
import 'package:dio/dio.dart';
class SubjectQaTextPageRepo {
Future<void> stopAIStreamingChatRespose({
required String difyAIAppApiKey,
required String taskId,
required String userId,
required Future Function(dynamic resBody) onSuccess,
}) async {
var requestData = jsonEncode({
"user": userId,
});
final responseBody = await DifyDioClient().post(
apiEndpointPath: '/chat-messages/$taskId/stop',
data: requestData,
headers: {
'Authorization': difyAIAppApiKey,
'Content-Type': 'application/json',
},
responseType: ResponseType.json);
if (responseBody != null) {
onSuccess(responseBody);
}
}
}
2. Are you using any specific configuration for the chat assistant that? The configuration of the test application for the chat assistant type is as follows: The configuration of the test application for the "ChatFlow" type is as follows: 3. Have you noticed if this behavior is consistent across different LLM providers?
|
The issue you're experiencing with the stop signal in "chat assistant" applications likely stems from differences in how the stop signal is handled internally compared to "ChatFlow-type" applications. Here are some key areas to investigate:
Providing logs that show the continued streaming after a success response could help identify where the stop signal is not being processed correctly. This information can be crucial for debugging the internal handling of the stop signal in "chat assistant" applications. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
1. In the chat assistant case, does the streaming eventually complete normally with the full response, or does it get cut off at some point? In my tests, I found that it seems to be interrupted during the next conversation that follows. 2. Are you seeing any error messages in the console/logs when the stop API is called? My frontend code console did not receive any exceptions or error messages. However, the backend Docker service console shows slight differences in the information between the two cases. The specific differences are as follows:
3. Could you check the network tab in your browser's developer tools to see if there are any differences in the response headers or connection status between the two application types when the stop API is called? I am currently using Flutter to develop the app and have not yet attempted adaptation for the web.
|
To address the issue with the stop signal in "chat assistant" applications, consider the following steps:
By focusing on these areas, you can pinpoint where the stop signal handling might be diverging between "chat assistant" and "ChatFlow-type" applications. If necessary, consider modifying the stop signal handling to bypass some intermediate layers for more immediate effect in chat assistant applications. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Of course, I'd be happy to!
|
To address the issue with the stop signal in "chat assistant" applications, consider implementing the following changes:
Testing these changes should help align the behavior of the Chat Assistant application with that of the ChatFlow application, ensuring consistent handling of stop signals across both application types. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
I'm very sorry, but I haven't delved into the development of the Dify backend yet. If testing is required, could you please tell me which file and where in the source code the modifications should be made, along with the detailed changes and corresponding actions?
|
The proposed changes to improve the handling of stop signals in the Chat Assistant mode seem well-targeted. Here's a summary of the key modifications and their expected outcomes:
Testing these changes should result in:
These changes should enhance the responsiveness and reliability of the stop signal handling in the Chat Assistant application. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Okay, how should I go about testing this PR?
|
After I modify the corresponding code, do I just need to run
|
This comment was marked as spam.
This comment was marked as spam.
OK!
|
This comment was marked as spam.
This comment was marked as spam.
To test the proposed changes in the PR for the Chat Assistant mode, follow these steps:
By following these steps, you can effectively test the changes and ensure that the stop signal handling in the Chat Assistant mode is responsive and reliable. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
This comment was marked as spam.
This comment was marked as spam.
I am getting started on it. |
This comment was marked as spam.
This comment was marked as spam.
To test the changes effectively, follow these specific test prompts and scenarios:
Key Points to Check:
By running these tests, you can confirm that the changes are working as intended and that the Chat Assistant mode behaves consistently with the ChatFlow applications. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
This comment was marked as spam.
This comment was marked as spam.
Great!I'll do my best to test it. |
This comment was marked as spam.
This comment was marked as spam.
Hey @dht-hedaihua! 😊 It looks like you're diving deep into testing scenarios and performance checks for your AI system. While I can help with technical questions and bug fixes, providing specific test prompts and monitoring guidelines is a bit outside my wheelhouse. If you think I should be able to assist with this, feel free to reach out to the Dosu Team. They're always eager to hear how I can be more helpful! To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
This comment was marked as spam.
This comment was marked as spam.
I encountered an issue midway: For Chat Assistant applications, when clicking the "Stop Response" button on the page after running the app, the message stream is successfully terminated as expected. I checked the console and found that the API path being called is: Since this API is functioning correctly, is it still necessary to proceed with the current code modifications and testing? Would it be more practical to migrate the logic of this working API to the problematic one? Alternatively, why not use the same logic for both APIs? |
To effectively test the stop functionality for the chat assistant application, focus on these key areas:
By focusing on these aspects, you can confirm that the stop functionality is working as intended and that the application maintains stability and resource efficiency. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
|
I'm unable to reproduce this. sending a message in Postman and stopping the stream via the task-id found in one of the chunks stops the task. |
Self Checks
Dify version
0.15.2
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
/chat-messages/:task_id/stop
interface was invoked as required.✔️ Expected Behavior
When invoking the
/chat-messages/:task_id/stop
interface for a "chat assistant" application, it should behave the same as when invoking the interface for a "ChatFlow-type" application: returning "success" as expected, and the corresponding streaming response should automatically terminate.❌ Actual Behavior
The following behaviors were observed:
The text was updated successfully, but these errors were encountered: