Przeglądaj źródła

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

imldy 1 rok temu
rodzic
commit
5e361f6748
3 zmienionych plików z 26 dodań i 2 usunięć
  1. 16 0
      app/components/model-config.tsx
  2. 4 1
      app/locales/cn.ts
  3. 6 1
      app/store/config.ts

+ 16 - 0
app/components/model-config.tsx

@@ -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}

+ 4 - 1
app/locales/cn.ts

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

+ 6 - 1
app/store/config.ts

@@ -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;
       },
     },