From 08fe3314d1683df8e000591365037fbf45768317 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sat, 11 Mar 2023 11:16:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20API3=E7=9A=84=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/config.js | 2 +- utils/message.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/utils/config.js b/utils/config.js index 80c549a..1c682eb 100644 --- a/utils/config.js +++ b/utils/config.js @@ -55,7 +55,7 @@ const defaultConfig = { noiseScaleW: 0.668, lengthScale: 1.2, initiativeChatGroups: [], - version: 'v2.1.3' + version: 'v2.1.4' } const _path = process.cwd() let config = {} diff --git a/utils/message.js b/utils/message.js index 585df0f..98962ac 100644 --- a/utils/message.js +++ b/utils/message.js @@ -86,6 +86,10 @@ export class OfficialChatGPTClient { referrer: 'https://chat.openai.com/chat' } const res = await this._fetch(url, option) + if (res.status !== 200) { + let body = await res.json() + throw new Error(JSON.stringify(body, null, 2)) + } const decoder = new TextDecoder('utf-8') const bodyBytes = await res.arrayBuffer() const bodyText = decoder.decode(bodyBytes)