Skip to content

Commit a3f0ba8

Browse files
authored
update/fix maximum token count, support 'chatgpt-4o-latest' (#565)
1 parent 495ccb0 commit a3f0ba8

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

service/src/chatgpt/index.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,37 +59,28 @@ export async function initApi(key: KeyConfig, chatModel: string, maxContextCount
5959
// The token limit includes the token count from both the message array sent and the model response.
6060

6161
// Check if the model type is GPT-4-turbo or newer
62+
if (model.toLowerCase().includes('gpt-4o-2024-08-06') || model.toLowerCase().includes('chatgpt-4o-latest')) {
63+
// 'gpt-4o-2024-08-06'/'chatgpt-4o-latest'
64+
options.maxModelTokens = 128000
65+
options.maxResponseTokens = 16384
66+
}
6267
if (model.toLowerCase().includes('gpt-4o') || model.toLowerCase().includes('gpt-4-turbo') || model.toLowerCase().includes('-preview')) {
63-
// If it's a 'gpt-4o'/'gpt-4-turbo'/'xxxx-preview' model, set the maxModelTokens to 128000
68+
// 'gpt-4o'/'gpt-4-turbo'/'xxxx-preview'
6469
options.maxModelTokens = 128000
6570
options.maxResponseTokens = 4096
6671
}
6772
else if (model.toLowerCase().includes('gpt-4')) {
68-
// If it's a 'gpt-4' model, set the maxModelTokens and maxResponseTokens to 8192 and 2048 respectively
73+
// 'gpt-4'
6974
options.maxModelTokens = 8192
70-
options.maxResponseTokens = 2048
75+
options.maxResponseTokens = 8192
7176
}
72-
// Check if the model type includes 'gpt-3.5-turbo'
73-
else if (model.toLowerCase().includes('gpt-3.5-turbo-instruct') || model.toLowerCase().includes('gpt-3.5-turbo-0613')) {
74-
// If it's a old 'gpt-3.5-turbo' model, set the maxModelTokens to 4096 and maxResponseTokens to 1024
77+
else if (model.toLowerCase().includes('gpt-3.5-turbo-instruct')) {
78+
// 'gpt-3.5-turbo-instruct'
7579
options.maxModelTokens = 4096
76-
options.maxResponseTokens = 1024
77-
}
78-
// Check if the model type includes 'gpt-3.5-turbo'
79-
else if (model.toLowerCase().includes('gpt-3.5-turbo')) {
80-
// If it's a 'gpt-3.5-turbo' model, set the maxModelTokens to 16385 and maxResponseTokens to 4096
81-
options.maxModelTokens = 16385
8280
options.maxResponseTokens = 4096
8381
}
84-
// Check if the model type includes '32k'
85-
else if (model.toLowerCase().includes('32k')) {
86-
// If it's a '32k' model, set the maxModelTokens to 32768 and maxResponseTokens to 8192
87-
options.maxModelTokens = 32768
88-
options.maxResponseTokens = 8192
89-
}
90-
// Check if the model type includes '16k'
91-
else if (model.toLowerCase().includes('16k')) {
92-
// If it's a '16k' model, set the maxModelTokens to 16385 and maxResponseTokens to 4096
82+
else if (model.toLowerCase().includes('gpt-3.5-turbo')) {
83+
// 'gpt-3.5-turbo'
9384
options.maxModelTokens = 16385
9485
options.maxResponseTokens = 4096
9586
}

0 commit comments

Comments
 (0)