Skip to content

Commit a51e1ab

Browse files
simonwu53Chanzhaoyu
authored andcommitted
feat: 当用gpt-4的API 时增加可用的 Max Tokens (Chanzhaoyu#729)
* fix: 用GPT-4 API时增加max token * style: eslint fix --------- Co-authored-by: Redon <790348264@qq.com>
1 parent 39f34d9 commit a51e1ab

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

service/src/chatgpt/index.ts

+13
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
3939
debug: true,
4040
}
4141

42+
// increase max token limit if use gpt-4
43+
if (model.toLowerCase().includes('gpt-4')) {
44+
// if use 32k model
45+
if (model.toLowerCase().includes('32k')) {
46+
options.maxModelTokens = 32768
47+
options.maxResponseTokens = 8192
48+
}
49+
else {
50+
options.maxModelTokens = 8192
51+
options.maxResponseTokens = 2048
52+
}
53+
}
54+
4255
if (isNotEmptyString(OPENAI_API_BASE_URL))
4356
options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`
4457

0 commit comments

Comments
 (0)