fix: 修复LogInterceptor 导致message不能流式吐字的问题
This commit is contained in:
@@ -7,6 +7,8 @@ import '../utils/tts_util.dart';
|
||||
|
||||
import '../utils/common_util.dart';
|
||||
|
||||
@Deprecated('ChatSseService Deprecated, Use ai_chat_core/ChatSseService instead')
|
||||
/// SSE 服务类,处理与后端的流式通信
|
||||
class ChatSseService {
|
||||
// 缓存用户ID和会话ID
|
||||
String? _cachedUserId;
|
||||
@@ -112,14 +114,17 @@ class ChatSseService {
|
||||
break;
|
||||
}
|
||||
if (line.startsWith('data:')) {
|
||||
print('SSE line: $line');
|
||||
final jsonStr = line.substring(5).trim();
|
||||
if (jsonStr == '[DONE]' || jsonStr.contains('message_end')) {
|
||||
TtsUtil.complete();
|
||||
onStreamResponse(messageId, responseText, true);
|
||||
break;
|
||||
}
|
||||
print('SSE json: $jsonStr');
|
||||
try {
|
||||
final jsonData = json.decode(jsonStr);
|
||||
print('SSE jsonData: $jsonData');
|
||||
if (jsonData.containsKey('conversation_id') &&
|
||||
_cachedConversationId == null) {
|
||||
_cachedConversationId = jsonData['conversation_id'];
|
||||
|
||||
Reference in New Issue
Block a user