From 01edad771713ffaf7e6039179d55fde002d58bca Mon Sep 17 00:00:00 2001 From: ChenZhaoYu <790348264@qq.com> Date: Thu, 9 Mar 2023 22:45:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/src/chatgpt/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index b3cb1e0..f486f88 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -31,11 +31,14 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI // More Info: https://github.com/transitive-bullshit/chatgpt-api if (process.env.OPENAI_API_KEY) { + const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL + const model = (typeof OPENAI_API_MODEL === 'string' && OPENAI_API_MODEL.length > 0) + ? OPENAI_API_MODEL + : 'gpt-3.5-turbo' + const options: ChatGPTAPIOptions = { apiKey: process.env.OPENAI_API_KEY, - completionParams: { - model: process.env.OPENAI_API_MODEL ?? 'gpt-3.5-turbo', - }, + completionParams: { model }, debug: false, } @@ -108,7 +111,6 @@ async function chatReplyProcess( } catch (error: any) { const code = error.statusCode - global.console.log(error) if (Reflect.has(ErrorCodeMessage, code)) return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] }) return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' })