From 0dd4fa0d076ce3683f8bc532a09cbc0762671012 Mon Sep 17 00:00:00 2001 From: Vinlic Date: Tue, 9 Apr 2024 10:32:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=8D=E5=BA=94=E4=B8=BAjson=E6=97=B6?= =?UTF-8?q?=E5=B0=86=E9=94=99=E8=AF=AF=E8=BE=93=E5=87=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 b0b0486..5c12354 100644 --- a/src/api/controllers/chat.ts +++ b/src/api/controllers/chat.ts @@ -215,12 +215,13 @@ async function createCompletion( responseType: "stream", } ); - - if (result.headers["content-type"].indexOf("text/event-stream") == -1) + if (result.headers["content-type"].indexOf("text/event-stream") == -1) { + result.data.on("data", buffer => logger.error(buffer.toString())); throw new APIException( EX.API_REQUEST_FAILED, `Stream response Content-Type invalid: ${result.headers["content-type"]}` ); + } const streamStartTime = util.timestamp(); // 接收流为输出文本 @@ -316,6 +317,7 @@ async function createCompletionStream( `Invalid response Content-Type:`, result.headers["content-type"] ); + result.data.on("data", buffer => logger.error(buffer.toString())); const transStream = new PassThrough(); transStream.end( `data: ${JSON.stringify({