Skip to content

Commit

Permalink
feat: 当用gpt-4的API 时增加可用的 Max Tokens (Chanzhaoyu#729)
Browse files Browse the repository at this point in the history
* fix: 用GPT-4 API时增加max token

* style: eslint fix

---------

Co-authored-by: Redon <790348264@qq.com>
  • Loading branch information
2 people authored and Equim-chan committed Mar 22, 2023
1 parent 2de70f6 commit 75b3bc2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion service/src/chatgpt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,22 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
const options: ChatGPTAPIOptions = {
apiKey: process.env.OPENAI_API_KEY,
completionParams: { model },
maxModelTokens: 32768,
debug: true,
}

// increase max token limit if use gpt-4
if (model.toLowerCase().includes('gpt-4')) {
// if use 32k model
if (model.toLowerCase().includes('32k')) {
options.maxModelTokens = 32768
options.maxResponseTokens = 8192
}
else {
options.maxModelTokens = 8192
options.maxResponseTokens = 2048
}
}

if (isNotEmptyString(process.env.SYSTEM_MESSAGE)) {
let now = new Date()
now = new Date(now.getTime() - (now.getTimezoneOffset()*60*1000))
Expand Down

0 comments on commit 75b3bc2

Please sign in to comment.