From 356a147facbe6eb086f6bd5719b609c02b598b66 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Mon, 6 Nov 2023 14:13:10 -0800 Subject: [PATCH] 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 61f6c3cb85c..032b589299b 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 c319e9c6f2c..2978651016c 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 }) { + diff --git a/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx b/frontend/src/components/LLMSelection/OpenAiOptions/index.jsx index b6957419ee6..0e6a890ade3 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" > - {["gpt-3.5-turbo", "gpt-4"].map((model) => { - return ( - - ); - })} + {["gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview", "gpt-4-32k"].map( + (model) => { + return ( + + ); + } + )} {customModels.length > 0 && ( diff --git a/server/utils/AiProviders/openAi/index.js b/server/utils/AiProviders/openAi/index.js index 91c11592f7f..1a5072f2c3c 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;