Skip to content

Commit

Permalink
πŸ› fix: Revert "πŸ› fix: clean up gpt-3.5 model" (#653)
Browse files Browse the repository at this point in the history
This reverts commit 9616783.
  • Loading branch information
arvinxx authored Dec 14, 2023
1 parent 4630322 commit b8b14fc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/chains/__tests__/summaryTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/chains/summaryTitle.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/const/modelTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, number> = {
[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,
Expand Down
16 changes: 16 additions & 0 deletions src/store/global/selectors/__snapshots__/settings.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/types/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit b8b14fc

Please sign in to comment.