Skip to content

Commit

Permalink
fix: 修复默认模型判断错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanzhaoyu committed Mar 9, 2023
1 parent eff787a commit 01edad7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions service/src/chatgpt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

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

0 comments on commit 01edad7

Please sign in to comment.