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 <[email protected]>
  • Loading branch information
2 people authored and jingChen55 committed Mar 27, 2023
1 parent 39f34d9 commit a51e1ab
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions service/src/chatgpt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
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(OPENAI_API_BASE_URL))
options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`

Expand Down

0 comments on commit a51e1ab

Please sign in to comment.