流传输耗时显示

This commit is contained in:
Vinlic 2024-03-13 22:58:50 +08:00
parent 4083abf4e0
commit efdf5a229c

View File

@ -192,8 +192,10 @@ async function createCompletion(messages: any[], refreshToken: string, useSearch
responseType: 'stream'
});
const streamStartTime = util.timestamp();
// 接收流为输出文本
const answer = await receiveStream(convId, result.data);
logger.success(`Stream has completed transfer ${util.timestamp() - streamStartTime}ms`);
// 异步移除会话,如果消息不合规,此操作可能会抛出数据库错误异常,请忽略
removeConversation(convId, refreshToken)
@ -236,10 +238,10 @@ async function createCompletionStream(messages: any[], refreshToken: string, use
validateStatus: () => true,
responseType: 'stream'
});
const streamStartTime = util.timestamp();
// 创建转换流将消息格式转换为gpt兼容格式
return createTransStream(convId, result.data, () => {
logger.success('Stream has completed transfer');
logger.success(`Stream has completed transfer ${util.timestamp() - streamStartTime}ms`);
// 流传输结束后异步移除会话,如果消息不合规,此操作可能会抛出数据库错误异常,请忽略
removeConversation(convId, refreshToken)
.catch(err => console.error(err));