feat: 当用gpt-4的API 时增加可用的 Max Tokens (#729)

* fix: 用GPT-4 API时增加max token

* style: eslint fix

---------

Co-authored-by: Redon <790348264@qq.com>
This commit is contained in:
吴杉(Shan Wu) 2023-03-22 12:31:04 +02:00 committed by GitHub
parent bf48eae9fe
commit 3e509f6663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -45,6 +45,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`