|
|
|
@ -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' })
|
|
|
|
|