forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #2392 from imldy/dev_SetInjectSystemPrompts
fix: enable `enableInjectSystemPrompts` attribute for old sessions
This commit is contained in:
commit
7073fd2f3b
@ -589,7 +589,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: StoreKey.Chat,
|
name: StoreKey.Chat,
|
||||||
version: 3,
|
version: 3.1,
|
||||||
migrate(persistedState, version) {
|
migrate(persistedState, version) {
|
||||||
const state = persistedState as any;
|
const state = persistedState as any;
|
||||||
const newState = JSON.parse(JSON.stringify(state)) as ChatStore;
|
const newState = JSON.parse(JSON.stringify(state)) as ChatStore;
|
||||||
@ -617,6 +617,23 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable `enableInjectSystemPrompts` attribute for old sessions.
|
||||||
|
// Resolve issue of old sessions not automatically enabling.
|
||||||
|
if (version < 3.1) {
|
||||||
|
newState.sessions.forEach((s) => {
|
||||||
|
if (
|
||||||
|
// Exclude those already set by user
|
||||||
|
!s.mask.modelConfig.hasOwnProperty("enableInjectSystemPrompts")
|
||||||
|
) {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return newState;
|
return newState;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user