Skip to content

Commit 3e509f6

Browse files
feat: 当用gpt-4的API 时增加可用的 Max Tokens (Chanzhaoyu#729)
* fix: 用GPT-4 API时增加max token * style: eslint fix --------- Co-authored-by: Redon <[email protected]>
1 parent bf48eae commit 3e509f6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

service/src/chatgpt/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
4545
debug: true,
4646
}
4747

48+
// increase max token limit if use gpt-4
49+
if (model.toLowerCase().includes('gpt-4')) {
50+
// if use 32k model
51+
if (model.toLowerCase().includes('32k')) {
52+
options.maxModelTokens = 32768
53+
options.maxResponseTokens = 8192
54+
}
55+
else {
56+
options.maxModelTokens = 8192
57+
options.maxResponseTokens = 2048
58+
}
59+
}
60+
4861
if (isNotEmptyString(OPENAI_API_BASE_URL))
4962
options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`
5063

0 commit comments

Comments
 (0)