From efdf5a229c07cc87f9f0da29ebfaeffcccde9a7e Mon Sep 17 00:00:00 2001 From: Vinlic Date: Wed, 13 Mar 2024 22:58:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E4=BC=A0=E8=BE=93=E8=80=97=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/controllers/chat.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/controllers/chat.ts b/src/api/controllers/chat.ts index ed032b9..ef83cfb 100644 --- a/src/api/controllers/chat.ts +++ b/src/api/controllers/chat.ts @@ -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));