@@ -58,36 +58,20 @@ export async function initApi(key: KeyConfig, chatModel: string, maxContextCount
58
58
// Set the token limits based on the model's type. This is because different models have different token limits.
59
59
// The token limit includes the token count from both the message array sent and the model response.
60
60
61
- // 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
61
+ if ( model . toLowerCase ( ) . includes ( 'gpt-4.1' ) ) {
62
+ // https://platform.openai.com/docs/models/gpt-4.1
63
+ options . maxModelTokens = 1047576
64
+ options . maxResponseTokens = 32768
66
65
}
67
- if ( model . toLowerCase ( ) . includes ( 'gpt-4o' ) || model . toLowerCase ( ) . includes ( 'gpt-4-turbo' ) || model . toLowerCase ( ) . includes ( '-preview ') ) {
68
- // 'gpt-4o'/' gpt-4-turbo'/'xxxx-preview'
66
+ else if ( model . toLowerCase ( ) . includes ( 'gpt-4o' ) ) {
67
+ // https://platform.openai.com/docs/models/ gpt-4o
69
68
options . maxModelTokens = 128000
70
- options . maxResponseTokens = 4096
71
- }
72
- else if ( model . toLowerCase ( ) . includes ( 'gpt-4' ) ) {
73
- // 'gpt-4'
74
- options . maxModelTokens = 8192
75
- options . maxResponseTokens = 8192
76
- }
77
- else if ( model . toLowerCase ( ) . includes ( 'gpt-3.5-turbo-instruct' ) ) {
78
- // 'gpt-3.5-turbo-instruct'
79
- options . maxModelTokens = 4096
80
- options . maxResponseTokens = 4096
81
- }
82
- else if ( model . toLowerCase ( ) . includes ( 'gpt-3.5-turbo' ) ) {
83
- // 'gpt-3.5-turbo'
84
- options . maxModelTokens = 16385
85
- options . maxResponseTokens = 4096
69
+ options . maxResponseTokens = 16384
86
70
}
87
71
// If none of the above, use the default values
88
72
else {
89
- options . maxModelTokens = 4096
90
- options . maxResponseTokens = 1024
73
+ options . maxModelTokens = 1047576
74
+ options . maxResponseTokens = 32768
91
75
}
92
76
93
77
if ( isNotEmptyString ( OPENAI_API_BASE_URL ) )
0 commit comments