From 2a20091f78043abb70aa703df4ca4fc83ee72b6a Mon Sep 17 00:00:00 2001 From: Chenglong Wang Date: Wed, 14 Aug 2024 16:35:37 +0800 Subject: [PATCH 1/2] Added summary model for claude LLMs. --- app/constant.ts | 1 + app/store/chat.ts | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/constant.ts b/app/constant.ts index d21f18f5a37..b83ac490d16 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -235,6 +235,7 @@ Latex block: $$e=mc^2$$ export const SUMMARIZE_MODEL = "gpt-4o-mini"; export const GEMINI_SUMMARIZE_MODEL = "gemini-pro"; +export const CLAUDE_SUMMARIZE_MODEL = "claude-3-haiku-20240307" export const KnowledgeCutOffDate: Record = { default: "2021-09", diff --git a/app/store/chat.ts b/app/store/chat.ts index 653926d1b02..efe36e65604 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -12,6 +12,7 @@ import { StoreKey, SUMMARIZE_MODEL, GEMINI_SUMMARIZE_MODEL, + CLAUDE_SUMMARIZE_MODEL, } from "../constant"; import { getClientApi } from "../client/api"; import type { @@ -92,21 +93,31 @@ function createEmptySession(): ChatSession { function getSummarizeModel(currentModel: string) { // if it is using gpt-* models, force to use 4o-mini to summarize + const configStore = useAppConfig.getState(); + const accessStore = useAccessStore.getState(); + const allModel = collectModelsWithDefaultModel( + configStore.models, + [configStore.customModels, accessStore.customModels].join(","), + accessStore.defaultModel, + ); + if (currentModel.startsWith("gpt")) { - const configStore = useAppConfig.getState(); - const accessStore = useAccessStore.getState(); - const allModel = collectModelsWithDefaultModel( - configStore.models, - [configStore.customModels, accessStore.customModels].join(","), - accessStore.defaultModel, - ); const summarizeModel = allModel.find( (m) => m.name === SUMMARIZE_MODEL && m.available, ); return summarizeModel?.name ?? currentModel; } if (currentModel.startsWith("gemini")) { - return GEMINI_SUMMARIZE_MODEL; + const summarizeModel = allModel.find( + (m) => m.name === GEMINI_SUMMARIZE_MODEL && m.available, + ); + return summarizeModel?.name ?? currentModel; + } + if (currentModel.startsWith("claude")) { + const summarizeModel = allModel.find( + (m) => m.name === CLAUDE_SUMMARIZE_MODEL && m.available, + ); + return summarizeModel?.name ?? currentModel; } return currentModel; } From 5f46413d6b31b466115e7ab2aff7589e0ca31900 Mon Sep 17 00:00:00 2001 From: Chenglong Wang Date: Thu, 15 Aug 2024 16:30:08 +0800 Subject: [PATCH 2/2] Update chat.ts for comments. --- app/store/chat.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index efe36e65604..046c4bd16da 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -92,7 +92,6 @@ function createEmptySession(): ChatSession { } function getSummarizeModel(currentModel: string) { - // if it is using gpt-* models, force to use 4o-mini to summarize const configStore = useAppConfig.getState(); const accessStore = useAccessStore.getState(); const allModel = collectModelsWithDefaultModel( @@ -100,7 +99,7 @@ function getSummarizeModel(currentModel: string) { [configStore.customModels, accessStore.customModels].join(","), accessStore.defaultModel, ); - + // if it is using gpt-* models, force to use 4o-mini to summarize if (currentModel.startsWith("gpt")) { const summarizeModel = allModel.find( (m) => m.name === SUMMARIZE_MODEL && m.available, @@ -113,6 +112,7 @@ function getSummarizeModel(currentModel: string) { ); return summarizeModel?.name ?? currentModel; } + // if it is using claude-* models, use claude-3-haiku-20240307 to summarize if (currentModel.startsWith("claude")) { const summarizeModel = allModel.find( (m) => m.name === CLAUDE_SUMMARIZE_MODEL && m.available,