diff --git a/app/constant.ts b/app/constant.ts index 8b28af323bbc..ba0b22c7f780 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -63,6 +63,8 @@ Knowledge cutoff: 2021-09 Current model: {{model}} Current time: {{time}}`; +export const SUMMARIZE_MODEL = "gpt-3.5-turbo"; + export const DEFAULT_MODELS = [ { name: "gpt-4", diff --git a/app/store/chat.ts b/app/store/chat.ts index bcdd99569dbd..20603fe48b04 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -11,6 +11,7 @@ import { DEFAULT_INPUT_TEMPLATE, DEFAULT_SYSTEM_TEMPLATE, StoreKey, + SUMMARIZE_MODEL, } from "../constant"; import { api, RequestMessage } from "../client/api"; import { ChatControllerPool } from "../client/controller"; @@ -80,6 +81,11 @@ function createEmptySession(): ChatSession { }; } +function getSummarizeModel(currentModel: string) { + // if it is using gpt-* models, force to use 3.5 to summarize + return currentModel.startsWith("gpt") ? SUMMARIZE_MODEL : currentModel; +} + interface ChatStore { sessions: ChatSession[]; currentSessionIndex: number; @@ -501,7 +507,7 @@ export const useChatStore = create()( api.llm.chat({ messages: topicMessages, config: { - model: "gpt-3.5-turbo", + model: getSummarizeModel(session.mask.modelConfig.model), }, onFinish(message) { get().updateCurrentSession( @@ -555,7 +561,11 @@ export const useChatStore = create()( date: "", }), ), - config: { ...modelConfig, stream: true, model: "gpt-3.5-turbo" }, + config: { + ...modelConfig, + stream: true, + model: getSummarizeModel(session.mask.modelConfig.model), + }, onUpdate(message) { session.memoryPrompt = message; },