From d34ec687022873484454b17fafc4a87edfad1d94 Mon Sep 17 00:00:00 2001 From: Timothy Carambat <rambat1010@gmail.com> Date: Mon, 6 Nov 2023 14:22:19 -0800 Subject: [PATCH] Add support for gpt-4-turbo 128K model (#340) resolves #336 Add support for gpt-4-turbo 128K model --- README.md | 2 +- .../LLMSelection/AzureAiOptions/index.jsx | 1 + .../LLMSelection/OpenAiOptions/index.jsx | 24 ++++++++++--------- server/utils/AiProviders/openAi/index.js | 11 ++++++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 61f6c3cb8..032b58929 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ This monorepo consists of three main sections: ### Requirements - `yarn` and `node` on your machine - `python` 3.9+ for running scripts in `collector/`. -- access to an LLM like `GPT-3.5`, `GPT-4`. +- access to an LLM like `GPT-3.5`, `GPT-4`, etc. - (optional) a vector database like Pinecone, qDrant, Weaviate, or Chroma*. *AnythingLLM by default uses a built-in vector db called LanceDB. diff --git a/frontend/src/components/LLMSelection/AzureAiOptions/index.jsx b/frontend/src/components/LLMSelection/AzureAiOptions/index.jsx index c319e9c6f..297865101 100644 --- a/frontend/src/components/LLMSelection/AzureAiOptions/index.jsx +++ b/frontend/src/components/LLMSelection/AzureAiOptions/index.jsx @@ -63,6 +63,7 @@ export default function AzureAiOptions({ settings }) { <option value={16384}>16,384 (gpt-3.5-16k)</option> <option value={8192}>8,192 (gpt-4)</option> <option value={32768}>32,768 (gpt-4-32k)</option> + <option value={128000}>128,000 (gpt-4-turbo)</option> </select> </div> diff --git a/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx b/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx index b6957419e..0e6a890ad 100644 --- a/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx +++ b/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx @@ -84,17 +84,19 @@ function OpenAIModelSelection({ apiKey, settings }) { className="bg-zinc-900 border border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" > <optgroup label="General LLM models"> - {["gpt-3.5-turbo", "gpt-4"].map((model) => { - return ( - <option - key={model} - value={model} - selected={settings.OpenAiModelPref === model} - > - {model} - </option> - ); - })} + {["gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview", "gpt-4-32k"].map( + (model) => { + return ( + <option + key={model} + value={model} + selected={settings.OpenAiModelPref === model} + > + {model} + </option> + ); + } + )} </optgroup> {customModels.length > 0 && ( <optgroup label="Your fine-tuned models"> diff --git a/server/utils/AiProviders/openAi/index.js b/server/utils/AiProviders/openAi/index.js index 91c11592f..1a5072f2c 100644 --- a/server/utils/AiProviders/openAi/index.js +++ b/server/utils/AiProviders/openAi/index.js @@ -25,13 +25,22 @@ class OpenAiLLM extends OpenAiEmbedder { return 4096; case "gpt-4": return 8192; + case "gpt-4-1106-preview": + return 128000; + case "gpt-4-32k": + return 32000; default: return 4096; // assume a fine-tune 3.5 } } async isValidChatCompletionModel(modelName = "") { - const validModels = ["gpt-4", "gpt-3.5-turbo"]; + const validModels = [ + "gpt-4", + "gpt-3.5-turbo", + "gpt-4-1106-preview", + "gpt-4-32k", + ]; const isPreset = validModels.some((model) => modelName === model); if (isPreset) return true;