fix: 修复默认模型判断错误

main
ChenZhaoYu 2 years ago
parent eff787a2b7
commit 01edad7717

@ -31,11 +31,14 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
// More Info: https://github.com/transitive-bullshit/chatgpt-api // More Info: https://github.com/transitive-bullshit/chatgpt-api
if (process.env.OPENAI_API_KEY) { 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 = { const options: ChatGPTAPIOptions = {
apiKey: process.env.OPENAI_API_KEY, apiKey: process.env.OPENAI_API_KEY,
completionParams: { completionParams: { model },
model: process.env.OPENAI_API_MODEL ?? 'gpt-3.5-turbo',
},
debug: false, debug: false,
} }
@ -108,7 +111,6 @@ async function chatReplyProcess(
} }
catch (error: any) { catch (error: any) {
const code = error.statusCode const code = error.statusCode
global.console.log(error)
if (Reflect.has(ErrorCodeMessage, code)) if (Reflect.has(ErrorCodeMessage, code))
return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] }) return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] })
return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' }) return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' })

Loading…
Cancel
Save