dev: 增加模型设置项:是否启用注入全局 System Prompt 功能

This commit is contained in:
imldy 2023-07-10 18:56:22 +08:00
parent c7e9f13d2e
commit 5e361f6748
3 changed files with 26 additions and 2 deletions

View File

@ -130,6 +130,22 @@ export function ModelConfigList(props: {
></InputRange>
</ListItem>
<ListItem
title={Locale.Settings.InjectSystemPrompts.Title}
subTitle={Locale.Settings.InjectSystemPrompts.SubTitle}
>
<input
type="checkbox"
checked={props.modelConfig.enableInjectSystemPrompts}
onChange={(e) =>
props.updateConfig(
(config) =>
(config.enableInjectSystemPrompts = e.currentTarget.checked),
)
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.InputTemplate.Title}
subTitle={Locale.Settings.InputTemplate.SubTitle}

View File

@ -139,7 +139,10 @@ const cn = {
Title: "字体大小",
SubTitle: "聊天内容的字体大小",
},
InjectSystemPrompts: {
Title: "注入系统级提示信息",
SubTitle: "强制给每次请求的消息列表开头添加一个系统级提示",
},
InputTemplate: {
Title: "用户输入预处理",
SubTitle: "用户最新的一条消息会填充到此模板",

View File

@ -47,6 +47,7 @@ export const DEFAULT_CONFIG = {
sendMemory: true,
historyMessageCount: 4,
compressMessageLengthThreshold: 1000,
enableInjectSystemPrompts: true,
template: DEFAULT_INPUT_TEMPLATE,
},
};
@ -146,7 +147,7 @@ export const useAppConfig = create<ChatConfigStore>()(
}),
{
name: StoreKey.Config,
version: 3.5,
version: 3.6,
migrate(persistedState, version) {
const state = persistedState as ChatConfig;
@ -165,6 +166,10 @@ export const useAppConfig = create<ChatConfigStore>()(
state.customModels = "claude,claude-100k";
}
if (version < 3.6) {
state.modelConfig.enableInjectSystemPrompts = true;
}
return state as any;
},
},