diff --git a/src/chains/__tests__/summaryTitle.test.ts b/src/chains/__tests__/summaryTitle.test.ts index 11bfa175..4d18a231 100644 --- a/src/chains/__tests__/summaryTitle.test.ts +++ b/src/chains/__tests__/summaryTitle.test.ts @@ -51,7 +51,7 @@ describe('chainSummaryTitle', () => { role: 'user', }, ], - model: LanguageModel.GPT4_PREVIEW, + model: LanguageModel.GPT3_5_16K, }); // Verify that getMessagesTokenCount was called with the correct messages @@ -97,7 +97,7 @@ describe('chainSummaryTitle', () => { role: 'user', }, ], - // No model specified since the token count is below the limit + model: 'gpt-3.5-turbo-16k', }); // Verify that getMessagesTokenCount was called with the correct messages diff --git a/src/chains/summaryTitle.ts b/src/chains/summaryTitle.ts index fdb907d0..08e66dff 100644 --- a/src/chains/summaryTitle.ts +++ b/src/chains/summaryTitle.ts @@ -1,4 +1,3 @@ -import { ModelTokens } from '@/const/modelTokens'; import { chatHelpers } from '@/store/chat/helpers'; import { globalHelpers } from '@/store/global/helpers'; import { LanguageModel } from '@/types/llm'; @@ -21,11 +20,11 @@ export const chainSummaryTitle = async ( role: 'user', }, ]; - // 如果超过 16k,则使用 GPT-4-turbo 模型 + // 如果超过 4k,则使用 GPT3.5 16K 模型 const tokens = await chatHelpers.getMessagesTokenCount(finalMessages); let model: LanguageModel | undefined = undefined; - if (tokens > ModelTokens[LanguageModel.GPT3_5]) { - model = LanguageModel.GPT4_PREVIEW; + if (tokens > 4000) { + model = LanguageModel.GPT3_5_16K; } return { diff --git a/src/const/modelTokens.ts b/src/const/modelTokens.ts index dd195e6e..082e4f64 100644 --- a/src/const/modelTokens.ts +++ b/src/const/modelTokens.ts @@ -2,7 +2,9 @@ import { LanguageModel } from '@/types/llm'; // refs to: https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo export const ModelTokens: Record = { - [LanguageModel.GPT3_5]: 16_385, + [LanguageModel.GPT3_5]: 4096, + [LanguageModel.GPT3_5_1106]: 16_385, + [LanguageModel.GPT3_5_16K]: 16_385, [LanguageModel.GPT4]: 8196, [LanguageModel.GPT4_PREVIEW]: 128_000, [LanguageModel.GPT4_VISION_PREVIEW]: 128_000, diff --git a/src/store/global/selectors/__snapshots__/settings.test.ts.snap b/src/store/global/selectors/__snapshots__/settings.test.ts.snap index 7a2f8168..d2094c38 100644 --- a/src/store/global/selectors/__snapshots__/settings.test.ts.snap +++ b/src/store/global/selectors/__snapshots__/settings.test.ts.snap @@ -23,6 +23,14 @@ exports[`settingsSelectors > CUSTOM_MODELS > duplicate naming model 1`] = ` "displayName": "gpt-3.5-turbo", "name": "gpt-3.5-turbo", }, + { + "displayName": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106", + }, + { + "displayName": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k", + }, { "displayName": "gpt-4", "name": "gpt-4", @@ -48,6 +56,14 @@ exports[`settingsSelectors > CUSTOM_MODELS > only add the model 1`] = ` "displayName": "gpt-3.5-turbo", "name": "gpt-3.5-turbo", }, + { + "displayName": "gpt-3.5-turbo-1106", + "name": "gpt-3.5-turbo-1106", + }, + { + "displayName": "gpt-3.5-turbo-16k", + "name": "gpt-3.5-turbo-16k", + }, { "displayName": "gpt-4", "name": "gpt-4", diff --git a/src/types/llm.ts b/src/types/llm.ts index 6631604f..dba33c2e 100644 --- a/src/types/llm.ts +++ b/src/types/llm.ts @@ -6,6 +6,8 @@ export enum LanguageModel { * GPT 3.5 Turbo */ GPT3_5 = 'gpt-3.5-turbo', + GPT3_5_1106 = 'gpt-3.5-turbo-1106', + GPT3_5_16K = 'gpt-3.5-turbo-16k', /** * GPT 4 */