From 8479ac72936ba196590637605bff4b3c9737fdc8 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 2 Feb 2024 01:01:11 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat:=20Support=20for=20GPT-3.5?= =?UTF-8?q?=20Turbo/0125=20Model=20(#1704)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚀 feat: Support for GPT-3.5 Turbo/0125 Model * ci: fix tx test --- .env.example | 4 ++-- api/models/tx.js | 3 +++ api/models/tx.spec.js | 3 +++ api/utils/tokens.js | 1 + api/utils/tokens.spec.js | 3 +++ docs/install/configuration/dotenv.md | 4 ++-- packages/data-provider/src/config.ts | 1 + 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 2a8ed9274c..13a834ea8e 100644 --- a/.env.example +++ b/.env.example @@ -101,7 +101,7 @@ GOOGLE_KEY=user_provided #============# OPENAI_API_KEY=user_provided -# OPENAI_MODELS=gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k +# OPENAI_MODELS=gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k DEBUG_OPENAI=false @@ -127,7 +127,7 @@ DEBUG_OPENAI=false # Plugins # #============# -# PLUGIN_MODELS=gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613 +# PLUGIN_MODELS=gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-0125,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613 DEBUG_PLUGINS=true diff --git a/api/models/tx.js b/api/models/tx.js index d3be0d8691..bb5dda561d 100644 --- a/api/models/tx.js +++ b/api/models/tx.js @@ -12,6 +12,7 @@ const tokenValues = { '16k': { prompt: 3, completion: 4 }, 'gpt-3.5-turbo-1106': { prompt: 1, completion: 2 }, 'gpt-4-1106': { prompt: 10, completion: 30 }, + 'gpt-3.5-turbo-0125': { prompt: 0.5, completion: 1.5 }, }; /** @@ -29,6 +30,8 @@ const getValueKey = (model, endpoint) => { if (modelName.includes('gpt-3.5-turbo-16k')) { return '16k'; + } else if (modelName.includes('gpt-3.5-turbo-0125')) { + return 'gpt-3.5-turbo-0125'; } else if (modelName.includes('gpt-3.5-turbo-1106')) { return 'gpt-3.5-turbo-1106'; } else if (modelName.includes('gpt-3.5')) { diff --git a/api/models/tx.spec.js b/api/models/tx.spec.js index a65d055fa3..36533a11dd 100644 --- a/api/models/tx.spec.js +++ b/api/models/tx.spec.js @@ -90,6 +90,9 @@ describe('getMultiplier', () => { expect(getMultiplier({ tokenType: 'completion', model: 'gpt-4-turbo-vision-preview' })).toBe( tokenValues['gpt-4-1106'].completion, ); + expect(getMultiplier({ tokenType: 'completion', model: 'gpt-3.5-turbo-0125' })).toBe( + tokenValues['gpt-3.5-turbo-0125'].completion, + ); }); it('should return defaultRate if derived valueKey does not match any known patterns', () => { diff --git a/api/utils/tokens.js b/api/utils/tokens.js index d2bc3d9bb8..0b36762eb7 100644 --- a/api/utils/tokens.js +++ b/api/utils/tokens.js @@ -55,6 +55,7 @@ const openAIModels = { 'gpt-3.5-turbo-16k': 16375, // -10 from max 'gpt-3.5-turbo-16k-0613': 16375, // -10 from max 'gpt-3.5-turbo-1106': 16375, // -10 from max + 'gpt-3.5-turbo-0125': 16375, // -10 from max 'mistral-': 31990, // -10 from max }; diff --git a/api/utils/tokens.spec.js b/api/utils/tokens.spec.js index 9ebe84b536..917bbf4cd5 100644 --- a/api/utils/tokens.spec.js +++ b/api/utils/tokens.spec.js @@ -92,6 +92,9 @@ describe('getModelMaxTokens', () => { expect(getModelMaxTokens('gpt-4-0125-preview')).toBe( maxTokensMap[EModelEndpoint.openAI]['gpt-4-0125'], ); + expect(getModelMaxTokens('gpt-3.5-turbo-0125')).toBe( + maxTokensMap[EModelEndpoint.openAI]['gpt-3.5-turbo-0125'], + ); }); test('should return correct tokens for Anthropic models', () => { diff --git a/docs/install/configuration/dotenv.md b/docs/install/configuration/dotenv.md index 7795b5b774..e231e73a82 100644 --- a/docs/install/configuration/dotenv.md +++ b/docs/install/configuration/dotenv.md @@ -317,7 +317,7 @@ DEBUG_OPENAI=false - Leave it blank or commented out to use internal settings. ```bash -OPENAI_MODELS=gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k +OPENAI_MODELS=gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k ``` - Titling is enabled by default when initiating a conversation. @@ -383,7 +383,7 @@ Here are some useful documentation about plugins: - Identify the available models, separated by commas **without spaces**. The first model in the list will be set as default. Leave it blank or commented out to use internal settings. ```bash -PLUGIN_MODELS=gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613 +PLUGIN_MODELS=gpt-4,gpt-4-turbo-preview,gpt-4-0125-preview,gpt-4-1106-preview,gpt-4-0613,gpt-3.5-turbo,gpt-3.5-turbo-0125,gpt-3.5-turbo-1106,gpt-3.5-turbo-0613 ``` - Set to false or comment out to disable debug mode for plugins diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index e21bf8fefe..364856510a 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -91,6 +91,7 @@ export const defaultModels = { 'claude-instant-1-100k', ], [EModelEndpoint.openAI]: [ + 'gpt-3.5-turbo-0125', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-16k', 'gpt-4-turbo-preview',