修复流模式传输完毕时未成功删除会话历史的问题

This commit is contained in:
Vinlic 2024-03-21 00:02:28 +08:00
parent b6cf5fcc16
commit c7ee175c18

View File

@ -272,7 +272,7 @@ async function createCompletionStream(messages: any[], refreshToken: string, ass
// 创建转换流将消息格式转换为gpt兼容格式
return createTransStream(result.data, (convId: string) => {
logger.success(`Stream has completed transfer ${util.timestamp() - streamStartTime}ms`);
// 流传输结束后异步移除会话,如果消息不合规,此操作可能会抛出数据库错误异常,请忽略
// 流传输结束后异步移除会话
removeConversation(convId, refreshToken, assistantId)
.catch(err => console.error(err));
});
@ -636,7 +636,7 @@ function createTransStream(stream: any, endCallback?: Function) {
!transStream.closed && transStream.write(data);
!transStream.closed && transStream.end('data: [DONE]\n\n');
content = '';
endCallback && endCallback();
endCallback && endCallback(result.conversation_id);
}
}
catch (err) {