From fd058cc6937d2d1647f07d4d440c68d60cae9f50 Mon Sep 17 00:00:00 2001 From: imldy Date: Sat, 15 Jul 2023 01:32:39 +0800 Subject: [PATCH 1/2] fix: enable `enableInjectSystemPrompts` attribute for old sessions --- app/store/chat.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index 6b403dd6..29fa027b 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -590,7 +590,7 @@ export const useChatStore = create()( }), { name: StoreKey.Chat, - version: 3, + version: 3.1, migrate(persistedState, version) { const state = persistedState as any; const newState = JSON.parse(JSON.stringify(state)) as ChatStore; @@ -618,6 +618,18 @@ export const useChatStore = create()( }); } + // Enable `enableInjectSystemPrompts` attribute for old sessions. + // Resolve issue of old sessions not automatically enabling. + if (version < 3.1) { + newState.sessions.forEach((s) => { + if ( + !s.mask.modelConfig.hasOwnProperty("enableInjectSystemPrompts") + ) { + s.mask.modelConfig.enableInjectSystemPrompts = true; + } + }); + } + return newState; }, }, From a9f67a48a1879f50f5f125ac09ff1bddf8edb05a Mon Sep 17 00:00:00 2001 From: imldy Date: Sat, 15 Jul 2023 02:48:47 +0800 Subject: [PATCH 2/2] dev: use current inject configuration --- app/store/chat.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index 29fa027b..6bcdc5c7 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -623,9 +623,14 @@ export const useChatStore = create()( if (version < 3.1) { newState.sessions.forEach((s) => { if ( + // Exclude those already set by user !s.mask.modelConfig.hasOwnProperty("enableInjectSystemPrompts") ) { - s.mask.modelConfig.enableInjectSystemPrompts = true; + // Because users may have changed this configuration, + // the user's current configuration is used instead of the default + const config = useAppConfig.getState(); + s.mask.modelConfig.enableInjectSystemPrompts = + config.modelConfig.enableInjectSystemPrompts; } }); }