From 3bd76b9156627116b8bbcf038e08e35d84438447 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Mon, 28 Aug 2023 00:02:52 +0800 Subject: [PATCH] feat: close #2580 only use 3.5 to summarize when not using custom models --- app/constant.ts | 2 ++ app/store/chat.ts | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/constant.ts b/app/constant.ts index 8b28af32..ba0b22c7 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 bcdd9956..20603fe4 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; },