Merge pull request #2344 from imldy/dev_SetInjectSystemPrompts

Dev: 给是否注入全局系统prompt提供一个开关
This commit is contained in:
Yifei Zhang 2023-07-10 21:51:06 +08:00 committed by GitHub
commit 69139cd85b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 101 additions and 6 deletions

View File

@ -130,6 +130,22 @@ export function ModelConfigList(props: {
></InputRange> ></InputRange>
</ListItem> </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 <ListItem
title={Locale.Settings.InputTemplate.Title} title={Locale.Settings.InputTemplate.Title}
subTitle={Locale.Settings.InputTemplate.SubTitle} subTitle={Locale.Settings.InputTemplate.SubTitle}

View File

@ -110,6 +110,11 @@ const ar: PartialLocaleType = {
Title: "حجم الخط", Title: "حجم الخط",
SubTitle: "ضبط حجم الخط لمحتوى الدردشة", SubTitle: "ضبط حجم الخط لمحتوى الدردشة",
}, },
InjectSystemPrompts: {
Title: "حقن تلميحات النظام",
SubTitle:
"قم بإضافة تلميحة نظام محاكاة ChatGPT إلى بداية قائمة الرسائل المُطلَبة في كل طلب",
},
InputTemplate: { InputTemplate: {
Title: "نموذج الإدخال", Title: "نموذج الإدخال",
SubTitle: "سيتم ملء أحدث رسالة في هذا النموذج", SubTitle: "سيتم ملء أحدث رسالة في هذا النموذج",

View File

@ -135,7 +135,11 @@ const bn: PartialLocaleType = {
Title: "ফন্ট সাইজ", Title: "ফন্ট সাইজ",
SubTitle: "চ্যাট সামগ্রীর ফন্ট সাইজ সংশোধন করুন", SubTitle: "চ্যাট সামগ্রীর ফন্ট সাইজ সংশোধন করুন",
}, },
InjectSystemPrompts: {
Title: "حقن تلميحات النظام",
SubTitle:
"قم بإضافة تلميحة نظام محاكاة ChatGPT إلى بداية قائمة الرسائل المُطلَبة في كل طلب",
},
InputTemplate: { InputTemplate: {
Title: "ইনপুট টেমপ্লেট", Title: "ইনপুট টেমপ্লেট",
SubTitle: "নতুনতম বার্তা এই টেমপ্লেটে পূরণ হবে", SubTitle: "নতুনতম বার্তা এই টেমপ্লেটে পূরণ হবে",

View File

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

View File

@ -71,6 +71,11 @@ const cs: PartialLocaleType = {
Title: "Velikost písma", Title: "Velikost písma",
SubTitle: "Nastavení velikosti písma obsahu chatu", SubTitle: "Nastavení velikosti písma obsahu chatu",
}, },
InjectSystemPrompts: {
Title: "Vložit systémové prompty",
SubTitle:
"Vynutit přidání simulovaného systémového promptu ChatGPT na začátek seznamu zpráv každého požadavku",
},
Update: { Update: {
Version: (x: string) => `Verze: ${x}`, Version: (x: string) => `Verze: ${x}`,
IsLatest: "Aktuální verze", IsLatest: "Aktuální verze",

View File

@ -71,6 +71,11 @@ const de: PartialLocaleType = {
Title: "Schriftgröße", Title: "Schriftgröße",
SubTitle: "Schriftgröße des Chat-Inhalts anpassen", SubTitle: "Schriftgröße des Chat-Inhalts anpassen",
}, },
InjectSystemPrompts: {
Title: "System-Prompts einfügen",
SubTitle:
"Erzwingt das Hinzufügen eines simulierten systemweiten Prompts von ChatGPT am Anfang der Nachrichtenliste bei jeder Anfrage",
},
Update: { Update: {
Version: (x: string) => `Version: ${x}`, Version: (x: string) => `Version: ${x}`,
IsLatest: "Neueste Version", IsLatest: "Neueste Version",

View File

@ -141,7 +141,11 @@ const en: LocaleType = {
Title: "Font Size", Title: "Font Size",
SubTitle: "Adjust font size of chat content", SubTitle: "Adjust font size of chat content",
}, },
InjectSystemPrompts: {
Title: "Inject System Prompts",
SubTitle:
"Forcefully add a simulated ChatGPT system prompt at the beginning of the message list for every request",
},
InputTemplate: { InputTemplate: {
Title: "Input Template", Title: "Input Template",
SubTitle: "Newest message will be filled to this template", SubTitle: "Newest message will be filled to this template",

View File

@ -71,6 +71,11 @@ const es: PartialLocaleType = {
Title: "Tamaño de fuente", Title: "Tamaño de fuente",
SubTitle: "Ajustar el tamaño de fuente del contenido del chat", SubTitle: "Ajustar el tamaño de fuente del contenido del chat",
}, },
InjectSystemPrompts: {
Title: "Inyectar Prompts del Sistema",
SubTitle:
"Agregar forzosamente un prompt de sistema simulado de ChatGPT al comienzo de la lista de mensajes en cada solicitud",
},
Update: { Update: {
Version: (x: string) => `Versión: ${x}`, Version: (x: string) => `Versión: ${x}`,
IsLatest: "Última versión", IsLatest: "Última versión",

View File

@ -111,6 +111,11 @@ const fr: PartialLocaleType = {
Title: "Taille des polices", Title: "Taille des polices",
SubTitle: "Ajuste la taille de police du contenu de la conversation", SubTitle: "Ajuste la taille de police du contenu de la conversation",
}, },
InjectSystemPrompts: {
Title: "Injecter des invites système",
SubTitle:
"Ajoute de force une invite système simulée de ChatGPT au début de la liste des messages pour chaque demande",
},
InputTemplate: { InputTemplate: {
Title: "Template", Title: "Template",
SubTitle: "Le message le plus récent sera ajouté à ce template.", SubTitle: "Le message le plus récent sera ajouté à ce template.",

View File

@ -71,6 +71,11 @@ const it: PartialLocaleType = {
Title: "Dimensione carattere", Title: "Dimensione carattere",
SubTitle: "Regolare la dimensione dei caratteri del contenuto della chat", SubTitle: "Regolare la dimensione dei caratteri del contenuto della chat",
}, },
InjectSystemPrompts: {
Title: "Inserisci Prompts di Sistema",
SubTitle:
"Aggiungi forzatamente un prompt di sistema simulato di ChatGPT all'inizio della lista dei messaggi per ogni richiesta",
},
Update: { Update: {
Version: (x: string) => `Versione: ${x}`, Version: (x: string) => `Versione: ${x}`,
IsLatest: "Ultima versione", IsLatest: "Ultima versione",

View File

@ -84,6 +84,11 @@ const jp: PartialLocaleType = {
Title: "フォントサイズ", Title: "フォントサイズ",
SubTitle: "チャット内容のフォントサイズ", SubTitle: "チャット内容のフォントサイズ",
}, },
InjectSystemPrompts: {
Title: "システムプロンプトの挿入",
SubTitle:
"各リクエストのメッセージリストの先頭に、ChatGPTのシステムプロンプトを強制的に追加します",
},
InputTemplate: { InputTemplate: {
Title: "入力の前処理", Title: "入力の前処理",
SubTitle: "新規入力がこのテンプレートに埋め込まれます", SubTitle: "新規入力がこのテンプレートに埋め込まれます",

View File

@ -71,6 +71,11 @@ const ko: PartialLocaleType = {
Title: "글꼴 크기", Title: "글꼴 크기",
SubTitle: "채팅 내용의 글꼴 크기 조정", SubTitle: "채팅 내용의 글꼴 크기 조정",
}, },
InjectSystemPrompts: {
Title: "시스템 프롬프트 주입",
SubTitle:
"각 요청의 메시지 목록의 시작에 ChatGPT 시스템 프롬프트를 강제로 추가합니다",
},
Update: { Update: {
Version: (x: string) => `버전: ${x}`, Version: (x: string) => `버전: ${x}`,
IsLatest: "최신 버전", IsLatest: "최신 버전",

View File

@ -65,6 +65,11 @@ const no: PartialLocaleType = {
Title: "Fontstørrelsen", Title: "Fontstørrelsen",
SubTitle: "Juster fontstørrelsen for samtaleinnholdet.", SubTitle: "Juster fontstørrelsen for samtaleinnholdet.",
}, },
InjectSystemPrompts: {
Title: "Sett inn systemprompter",
SubTitle:
"Tving tillegg av en simulert ChatGPT-systemprompt i begynnelsen av meldingslisten for hver forespørsel",
},
Update: { Update: {
Version: (x: string) => `Versjon: ${x}`, Version: (x: string) => `Versjon: ${x}`,
IsLatest: "Siste versjon", IsLatest: "Siste versjon",

View File

@ -71,6 +71,11 @@ const ru: PartialLocaleType = {
Title: "Размер шрифта", Title: "Размер шрифта",
SubTitle: "Настроить размер шрифта контента чата", SubTitle: "Настроить размер шрифта контента чата",
}, },
InjectSystemPrompts: {
Title: "Вставить системные подсказки",
SubTitle:
"Принудительно добавить симулированную системную подсказку ChatGPT в начало списка сообщений для каждого запроса",
},
Update: { Update: {
Version: (x: string) => `Версия: ${x}`, Version: (x: string) => `Версия: ${x}`,
IsLatest: "Последняя версия", IsLatest: "Последняя версия",

View File

@ -71,6 +71,11 @@ const tr: PartialLocaleType = {
Title: "Yazı Boyutu", Title: "Yazı Boyutu",
SubTitle: "Sohbet içeriğinin yazı boyutunu ayarlayın", SubTitle: "Sohbet içeriğinin yazı boyutunu ayarlayın",
}, },
InjectSystemPrompts: {
Title: "Sistem İpucu Ekleyin",
SubTitle:
"Her istek için ileti listesinin başına simüle edilmiş bir ChatGPT sistem ipucu ekleyin",
},
Update: { Update: {
Version: (x: string) => `Sürüm: ${x}`, Version: (x: string) => `Sürüm: ${x}`,
IsLatest: "En son sürüm", IsLatest: "En son sürüm",

View File

@ -69,6 +69,10 @@ const tw: PartialLocaleType = {
Title: "字型大小", Title: "字型大小",
SubTitle: "聊天內容的字型大小", SubTitle: "聊天內容的字型大小",
}, },
InjectSystemPrompts: {
Title: "注入系統提示",
SubTitle: "強制在每個請求的訊息列表開頭添加一個模擬 ChatGPT 的系統提示",
},
Update: { Update: {
Version: (x: string) => `當前版本:${x}`, Version: (x: string) => `當前版本:${x}`,
IsLatest: "已是最新版本", IsLatest: "已是最新版本",

View File

@ -71,6 +71,11 @@ const vi: PartialLocaleType = {
Title: "Font chữ", Title: "Font chữ",
SubTitle: "Thay đổi font chữ của nội dung trò chuyện", SubTitle: "Thay đổi font chữ của nội dung trò chuyện",
}, },
InjectSystemPrompts: {
Title: "Tiêm Prompt Hệ thống",
SubTitle:
"Bắt buộc thêm một prompt hệ thống giả lập ChatGPT ở đầu danh sách tin nhắn cho mỗi yêu cầu",
},
Update: { Update: {
Version: (x: string) => `Phiên bản: ${x}`, Version: (x: string) => `Phiên bản: ${x}`,
IsLatest: "Phiên bản mới nhất", IsLatest: "Phiên bản mới nhất",

View File

@ -387,8 +387,7 @@ export const useChatStore = create<ChatStore>()(
const contextPrompts = session.mask.context.slice(); const contextPrompts = session.mask.context.slice();
// system prompts, to get close to OpenAI Web ChatGPT // system prompts, to get close to OpenAI Web ChatGPT
// only will be injected if user does not use a mask or set none context prompts const shouldInjectSystemPrompts = modelConfig.enableInjectSystemPrompts;
const shouldInjectSystemPrompts = contextPrompts.length === 0;
const systemPrompts = shouldInjectSystemPrompts const systemPrompts = shouldInjectSystemPrompts
? [ ? [
createMessage({ createMessage({

View File

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