From cd1f082c52e46b23ba844e6b1813c20f164d7116 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Tue, 7 Nov 2023 06:08:06 +0700 Subject: [PATCH 1/3] Feat Models [GPT-4] [GPT-3.5] [128K context] [+] feat(constant.ts): add new models to DEFAULT_MODELS array --- app/constant.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index e03e00971cc..15db37a1ae6 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -100,6 +100,14 @@ export const DEFAULT_MODELS = [ name: "gpt-4-32k-0613", available: true, }, + { + name: "ggpt-4-1106-preview", + available: true, + }, + { + name: "gpt-4-vision-preview", + available: true, + }, { name: "gpt-3.5-turbo", available: true, @@ -112,6 +120,10 @@ export const DEFAULT_MODELS = [ name: "gpt-3.5-turbo-0613", available: true, }, + { + name: "gpt-3.5-turbo-1106", + available: true, + }, { name: "gpt-3.5-turbo-16k", available: true, From 9f26c8cecb997e3c1f81f5219f91043dc00342d9 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Tue, 7 Nov 2023 06:33:07 +0700 Subject: [PATCH 2/3] Fix Typo [GPT-4] [+] fix(constant.ts): fix typo in model name, change "ggpt-4-1106-preview" to "gpt-4-1106-preview" --- app/constant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/constant.ts b/app/constant.ts index 15db37a1ae6..5f3744ec181 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -101,7 +101,7 @@ export const DEFAULT_MODELS = [ available: true, }, { - name: "ggpt-4-1106-preview", + name: "gpt-4-1106-preview", available: true, }, { From d2d615c84a6a30879488528c4537e5a3ecaebca5 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Tue, 7 Nov 2023 06:42:55 +0700 Subject: [PATCH 3/3] Refactor KnowledgeCutoff [+] fix(constant.ts): update DEFAULT_SYSTEM_TEMPLATE to include knowledgeCutoff and time variables [+] feat(chat.ts): add support for injecting system prompts based on model configuration --- app/constant.ts | 5 +++-- app/store/chat.ts | 34 +++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/constant.ts b/app/constant.ts index 5f3744ec181..95de35627b9 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -69,9 +69,10 @@ export const OpenaiPath = { export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang export const DEFAULT_SYSTEM_TEMPLATE = ` You are ChatGPT, a large language model trained by OpenAI. -Knowledge cutoff: 2021-09 +Knowledge cutoff: {{knowledgeCutoff}} Current model: {{model}} -Current time: {{time}}`; +Current time: {{time}} +`; export const SUMMARIZE_MODEL = "gpt-3.5-turbo"; diff --git a/app/store/chat.ts b/app/store/chat.ts index 56ac8db6cc1..9f73fdf2675 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -401,22 +401,26 @@ export const useChatStore = createPersistStore( // system prompts, to get close to OpenAI Web ChatGPT const shouldInjectSystemPrompts = modelConfig.enableInjectSystemPrompts; - const systemPrompts = shouldInjectSystemPrompts - ? [ - createMessage({ - role: "system", - content: fillTemplateWith("", { - ...modelConfig, - template: DEFAULT_SYSTEM_TEMPLATE, - }), - }), - ] - : []; + let systemPrompts = shouldInjectSystemPrompts ? [] : []; + if (shouldInjectSystemPrompts) { - console.log( - "[Global System Prompt] ", - systemPrompts.at(0)?.content ?? "empty", - ); + const model = modelConfig.model; + let systemTemplate = DEFAULT_SYSTEM_TEMPLATE; + + if (model === "gpt-4-1106-preview" || model === "gpt-4-vision-preview") { + systemTemplate = systemTemplate.replace("{{knowledgeCutoff}}", "2023-04"); + } else { + systemTemplate = systemTemplate.replace("{{knowledgeCutoff}}", "2021-09"); + } + + const systemPrompt = createMessage({ + role: "system", + content: fillTemplateWith("", { + ...modelConfig, + template: systemTemplate, + }), + }); + console.log("[Global System Prompt] ", systemPrompt.content); } // long term memory