From 941f40afb5ae18460ee597194a7f70b001857ae5 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Fri, 17 May 2024 13:15:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=BB=BA=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=8F=AF=E4=BB=A5=E7=BB=A7=E6=89=BF=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/sidebar.tsx | 3 ++- app/store/chat.ts | 9 +++++++-- app/store/config.ts | 15 ++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 42f7d1502..509943bb9 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -130,6 +130,7 @@ function useDragSideBar() { export function SideBar(props: { className?: string }) { const chatStore = useChatStore(); + const currentModel = chatStore.currentSession().mask.modelConfig.model; // drag side bar const { onDragStart, shouldNarrow } = useDragSideBar(); const navigate = useNavigate(); @@ -248,7 +249,7 @@ export function SideBar(props: { className?: string }) { text={shouldNarrow ? undefined : Locale.Home.NewChat} onClick={() => { if (config.dontShowMaskSplashScreen) { - chatStore.newSession(); + chatStore.newSession(undefined, currentModel); navigate(Path.Chat); } else { navigate(Path.NewChat); diff --git a/app/store/chat.ts b/app/store/chat.ts index 2c155ebde..618b7fd8f 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -221,9 +221,14 @@ export const useChatStore = createPersistStore( }); }, - newSession(mask?: Mask) { + newSession(mask?: Mask, currentModel?: Mask["modelConfig"]["model"]) { const session = createEmptySession(); - + const config = useAppConfig.getState(); + console.log("------", session, "2222", config); + // 继承当前会话的模型 + if (currentModel) { + session.mask.modelConfig.model = currentModel; + } if (mask) { const config = useAppConfig.getState(); const globalModelConfig = config.modelConfig; diff --git a/app/store/config.ts b/app/store/config.ts index c2f1cd6e6..b35ba6d27 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -52,7 +52,7 @@ export const DEFAULT_CONFIG = { dontUseModel: DISABLE_MODELS, modelConfig: { - model: "gpt-35-turbo-0125" as ModelType, + model: "gpt-3.5-turbo-0125" as ModelType, temperature: 0.8, top_p: 1, max_tokens: 2000, @@ -138,7 +138,7 @@ export const useAppConfig = createPersistStore( }), { name: StoreKey.Config, - version: 3.9, + version: 3.91, migrate(persistedState, version) { const state = persistedState as ChatConfig; @@ -174,11 +174,12 @@ export const useAppConfig = createPersistStore( // return { ...DEFAULT_CONFIG }; // } - if (version < 3.9) { - state.modelConfig.template = - state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE - ? state.modelConfig.template - : config?.template ?? DEFAULT_INPUT_TEMPLATE; + if (version < 3.91) { + state.modelConfig = DEFAULT_CONFIG.modelConfig; + // state.modelConfig.template = + // state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE + // ? state.modelConfig.template + // : config?.template ?? DEFAULT_INPUT_TEMPLATE; } return state as any;