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>
</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

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

View File

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

View File

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

View File

@ -71,6 +71,11 @@ const cs: PartialLocaleType = {
Title: "Velikost písma",
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: {
Version: (x: string) => `Verze: ${x}`,
IsLatest: "Aktuální verze",

View File

@ -71,6 +71,11 @@ const de: PartialLocaleType = {
Title: "Schriftgröße",
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: {
Version: (x: string) => `Version: ${x}`,
IsLatest: "Neueste Version",

View File

@ -141,7 +141,11 @@ const en: LocaleType = {
Title: "Font Size",
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: {
Title: "Input Template",
SubTitle: "Newest message will be filled to this template",

View File

@ -71,6 +71,11 @@ const es: PartialLocaleType = {
Title: "Tamaño de fuente",
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: {
Version: (x: string) => `Versión: ${x}`,
IsLatest: "Última versión",

View File

@ -111,6 +111,11 @@ const fr: PartialLocaleType = {
Title: "Taille des polices",
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: {
Title: "Template",
SubTitle: "Le message le plus récent sera ajouté à ce template.",

View File

@ -71,6 +71,11 @@ const it: PartialLocaleType = {
Title: "Dimensione carattere",
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: {
Version: (x: string) => `Versione: ${x}`,
IsLatest: "Ultima versione",

View File

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

View File

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

View File

@ -65,6 +65,11 @@ const no: PartialLocaleType = {
Title: "Fontstørrelsen",
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: {
Version: (x: string) => `Versjon: ${x}`,
IsLatest: "Siste versjon",

View File

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

View File

@ -71,6 +71,11 @@ const tr: PartialLocaleType = {
Title: "Yazı Boyutu",
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: {
Version: (x: string) => `Sürüm: ${x}`,
IsLatest: "En son sürüm",

View File

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

View File

@ -71,6 +71,11 @@ const vi: PartialLocaleType = {
Title: "Font chữ",
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: {
Version: (x: string) => `Phiên bản: ${x}`,
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();
// 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 = contextPrompts.length === 0;
const shouldInjectSystemPrompts = modelConfig.enableInjectSystemPrompts;
const systemPrompts = shouldInjectSystemPrompts
? [
createMessage({

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