Skip to content

Commit 01edad7

Browse files
committed
fix: 修复默认模型判断错误
1 parent eff787a commit 01edad7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

service/src/chatgpt/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
3131
// More Info: https://github.com/transitive-bullshit/chatgpt-api
3232

3333
if (process.env.OPENAI_API_KEY) {
34+
const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL
35+
const model = (typeof OPENAI_API_MODEL === 'string' && OPENAI_API_MODEL.length > 0)
36+
? OPENAI_API_MODEL
37+
: 'gpt-3.5-turbo'
38+
3439
const options: ChatGPTAPIOptions = {
3540
apiKey: process.env.OPENAI_API_KEY,
36-
completionParams: {
37-
model: process.env.OPENAI_API_MODEL ?? 'gpt-3.5-turbo',
38-
},
41+
completionParams: { model },
3942
debug: false,
4043
}
4144

@@ -108,7 +111,6 @@ async function chatReplyProcess(
108111
}
109112
catch (error: any) {
110113
const code = error.statusCode
111-
global.console.log(error)
112114
if (Reflect.has(ErrorCodeMessage, code))
113115
return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] })
114116
return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' })

0 commit comments

Comments
 (0)