Skip to content

Commit 0ffdfdd

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 8eb9e50 commit 0ffdfdd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

service/src/chatgpt/index.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,20 @@ export async function initApi() {
4343
debug: true,
4444
}
4545

46-
if (isNotEmptyString(config.apiBaseUrl))
47-
options.apiBaseUrl = config.apiBaseUrl
46+
if (model.toLowerCase().includes('gpt-4')) {
47+
// if use 32k model
48+
if (model.toLowerCase().includes('32k')) {
49+
options.maxModelTokens = 32768
50+
options.maxResponseTokens = 8192
51+
}
52+
else {
53+
options.maxModelTokens = 8192
54+
options.maxResponseTokens = 2048
55+
}
56+
}
4857

58+
if (isNotEmptyString(config.apiBaseUrl))
59+
options.apiBaseUrl = `${config.apiBaseUrl}/v1`
4960
await setupProxy(options)
5061

5162
api = new ChatGPTAPI({ ...options })

0 commit comments

Comments
 (0)