diff --git a/default/content/presets/instruct/Adventure.json b/default/content/presets/instruct/Adventure.json index 827c6d5c9..a4093dff7 100644 --- a/default/content/presets/instruct/Adventure.json +++ b/default/content/presets/instruct/Adventure.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Adventure" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Alpaca-Roleplay.json b/default/content/presets/instruct/Alpaca-Roleplay.json index 5a5054340..b5aec1c92 100644 --- a/default/content/presets/instruct/Alpaca-Roleplay.json +++ b/default/content/presets/instruct/Alpaca-Roleplay.json @@ -19,5 +19,6 @@ "system_suffix": "\n\n", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Alpaca-Roleplay" } diff --git a/default/content/presets/instruct/Alpaca-Single-Turn.json b/default/content/presets/instruct/Alpaca-Single-Turn.json index 6a6f052d2..9baca108c 100644 --- a/default/content/presets/instruct/Alpaca-Single-Turn.json +++ b/default/content/presets/instruct/Alpaca-Single-Turn.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Alpaca-Single-Turn" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Alpaca.json b/default/content/presets/instruct/Alpaca.json index 96fd2cc83..28b2065fb 100644 --- a/default/content/presets/instruct/Alpaca.json +++ b/default/content/presets/instruct/Alpaca.json @@ -19,5 +19,6 @@ "system_suffix": "\n\n", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Alpaca" } diff --git a/default/content/presets/instruct/ChatML.json b/default/content/presets/instruct/ChatML.json index 348ae2458..513a72820 100644 --- a/default/content/presets/instruct/ChatML.json +++ b/default/content/presets/instruct/ChatML.json @@ -19,5 +19,6 @@ "system_suffix": "<|im_end|>\n", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "ChatML" } diff --git a/default/content/presets/instruct/DreamGen Role-Play V1.json b/default/content/presets/instruct/DreamGen Role-Play V1.json index 07f0301fc..002878b4d 100644 --- a/default/content/presets/instruct/DreamGen Role-Play V1.json +++ b/default/content/presets/instruct/DreamGen Role-Play V1.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "DreamGen Role-Play V1" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Koala.json b/default/content/presets/instruct/Koala.json index 980482c1a..f5db8ff48 100644 --- a/default/content/presets/instruct/Koala.json +++ b/default/content/presets/instruct/Koala.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Koala" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Libra-32B.json b/default/content/presets/instruct/Libra-32B.json index 6014546f6..c665eb364 100644 --- a/default/content/presets/instruct/Libra-32B.json +++ b/default/content/presets/instruct/Libra-32B.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Libra-32B" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Lightning 1.1.json b/default/content/presets/instruct/Lightning 1.1.json index bf79e1358..9f9bd7ccf 100644 --- a/default/content/presets/instruct/Lightning 1.1.json +++ b/default/content/presets/instruct/Lightning 1.1.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Lightning 1.1" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Llama 2 Chat.json b/default/content/presets/instruct/Llama 2 Chat.json index aeb4e13fd..dc507b777 100644 --- a/default/content/presets/instruct/Llama 2 Chat.json +++ b/default/content/presets/instruct/Llama 2 Chat.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.", "system_same_as_user": true, + "last_system_sequence": "", "name": "Llama 2 Chat" } diff --git a/default/content/presets/instruct/Metharme.json b/default/content/presets/instruct/Metharme.json index 1c8474cdf..195fe5260 100644 --- a/default/content/presets/instruct/Metharme.json +++ b/default/content/presets/instruct/Metharme.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Metharme" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Mistral.json b/default/content/presets/instruct/Mistral.json index 4f35139fa..bd3a9ff3c 100644 --- a/default/content/presets/instruct/Mistral.json +++ b/default/content/presets/instruct/Mistral.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.", "system_same_as_user": true, + "last_system_sequence": "", "name": "Mistral" } diff --git a/default/content/presets/instruct/OpenOrca-OpenChat.json b/default/content/presets/instruct/OpenOrca-OpenChat.json index 924ea94f7..04d526d4d 100644 --- a/default/content/presets/instruct/OpenOrca-OpenChat.json +++ b/default/content/presets/instruct/OpenOrca-OpenChat.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "OpenOrca-OpenChat" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Pygmalion.json b/default/content/presets/instruct/Pygmalion.json index 6278c0d23..cb5b60d8a 100644 --- a/default/content/presets/instruct/Pygmalion.json +++ b/default/content/presets/instruct/Pygmalion.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Pygmalion" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Story.json b/default/content/presets/instruct/Story.json index 1e42d3281..5c6b00cf0 100644 --- a/default/content/presets/instruct/Story.json +++ b/default/content/presets/instruct/Story.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "Story" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Synthia.json b/default/content/presets/instruct/Synthia.json index 24ec4849e..21fa535c0 100644 --- a/default/content/presets/instruct/Synthia.json +++ b/default/content/presets/instruct/Synthia.json @@ -19,5 +19,6 @@ "system_suffix": "\n", "user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.", "system_same_as_user": false, + "last_system_sequence": "", "name": "Synthia" } diff --git a/default/content/presets/instruct/Vicuna 1.0.json b/default/content/presets/instruct/Vicuna 1.0.json index fbc8a2bf5..d96bf4cb2 100644 --- a/default/content/presets/instruct/Vicuna 1.0.json +++ b/default/content/presets/instruct/Vicuna 1.0.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Vicuna 1.0" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Vicuna 1.1.json b/default/content/presets/instruct/Vicuna 1.1.json index a31698d03..a42e4fbfc 100644 --- a/default/content/presets/instruct/Vicuna 1.1.json +++ b/default/content/presets/instruct/Vicuna 1.1.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "Vicuna 1.1" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/WizardLM-13B.json b/default/content/presets/instruct/WizardLM-13B.json index 21e7bd555..b15fea56f 100644 --- a/default/content/presets/instruct/WizardLM-13B.json +++ b/default/content/presets/instruct/WizardLM-13B.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": true, + "last_system_sequence": "", "name": "WizardLM-13B" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/WizardLM.json b/default/content/presets/instruct/WizardLM.json index 198f6a062..18e808da4 100644 --- a/default/content/presets/instruct/WizardLM.json +++ b/default/content/presets/instruct/WizardLM.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "WizardLM" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/simple-proxy-for-tavern.json b/default/content/presets/instruct/simple-proxy-for-tavern.json index 14d32d86c..986da1697 100644 --- a/default/content/presets/instruct/simple-proxy-for-tavern.json +++ b/default/content/presets/instruct/simple-proxy-for-tavern.json @@ -19,5 +19,6 @@ "system_suffix": "", "user_alignment_message": "", "system_same_as_user": false, + "last_system_sequence": "", "name": "simple-proxy-for-tavern" -} \ No newline at end of file +} diff --git a/public/index.html b/public/index.html index f4b1586c7..034942754 100644 --- a/public/index.html +++ b/public/index.html @@ -3034,12 +3034,12 @@
-
-
+
+
+ +
+ +
+
+
diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index d90ffb9bc..7fc924274 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -26,6 +26,7 @@ const controls = [ { id: 'instruct_output_suffix', property: 'output_suffix', isCheckbox: false }, { id: 'instruct_system_sequence', property: 'system_sequence', isCheckbox: false }, { id: 'instruct_system_suffix', property: 'system_suffix', isCheckbox: false }, + { id: 'instruct_last_system_sequence', property: 'last_system_sequence', isCheckbox: false }, { id: 'instruct_user_alignment_message', property: 'user_alignment_message', isCheckbox: false }, { id: 'instruct_stop_sequence', property: 'stop_sequence', isCheckbox: false }, { id: 'instruct_names', property: 'names', isCheckbox: true }, @@ -56,6 +57,7 @@ function migrateInstructModeSettings(settings) { system_sequence: '', system_suffix: '', user_alignment_message: '', + last_system_sequence: '', names_force_groups: true, skip_examples: false, system_same_as_user: false, @@ -249,8 +251,9 @@ export function getInstructStoppingSequences() { const first_output_sequence = power_user.instruct.first_output_sequence?.replace(/{{name}}/gi, name2) || ''; const last_output_sequence = power_user.instruct.last_output_sequence?.replace(/{{name}}/gi, name2) || ''; const system_sequence = power_user.instruct.system_sequence?.replace(/{{name}}/gi, 'System') || ''; + const last_system_sequence = power_user.instruct.last_system_sequence?.replace(/{{name}}/gi, 'System') || ''; - const combined_sequence = `${stop_sequence}\n${input_sequence}\n${output_sequence}\n${first_output_sequence}\n${last_output_sequence}\n${system_sequence}`; + const combined_sequence = `${stop_sequence}\n${input_sequence}\n${output_sequence}\n${first_output_sequence}\n${last_output_sequence}\n${system_sequence}\n${last_system_sequence}`; combined_sequence.split('\n').filter((line, index, self) => self.indexOf(line) === index).forEach(addInstructSequence); } @@ -452,9 +455,10 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1, return power_user.instruct.input_sequence; } - // Neutral / system prompt + // Neutral / system / quiet prompt + // Use a special quiet instruct sequence if defined, or assistant's output sequence otherwise if (isQuiet && !isQuietToLoud) { - return power_user.instruct.output_sequence; + return power_user.instruct.last_system_sequence || power_user.instruct.output_sequence; } // Quiet in-character prompt @@ -517,20 +521,28 @@ export function replaceInstructMacros(input) { if (!input) { return ''; } + const instructMacros = { + 'instructSystem|instructSystemPrompt': power_user.instruct.system_prompt, + 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix, + 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix, + 'instructInput|instructUserPrefix': power_user.instruct.input_sequence, + 'instructUserSuffix': power_user.instruct.input_suffix, + 'instructOutput|instructAssistantPrefix': power_user.instruct.output_sequence, + 'instructSeparator|instructAssistantSuffix': power_user.instruct.output_suffix, + 'instructSystemPrefix': power_user.instruct.system_sequence, + 'instructSystemSuffix': power_user.instruct.system_suffix, + 'instructFirstOutput|instructFirstAssistantPrefix': power_user.instruct.first_output_sequence || power_user.instruct.output_sequence, + 'instructLastOutput|instructLastAssistantPrefix': power_user.instruct.last_output_sequence || power_user.instruct.output_sequence, + 'instructStop': power_user.instruct.stop_sequence, + 'instructUserFiller': power_user.instruct.user_alignment_message, + 'instructSystemInstructionPrefix': power_user.instruct.last_system_sequence, + }; + + for (const [placeholder, value] of Object.entries(instructMacros)) { + const regex = new RegExp(`{{(${placeholder})}}`, 'gi'); + input = input.replace(regex, power_user.instruct.enabled ? value : ''); + } - input = input.replace(/{{(instructSystem|instructSystemPrompt)}}/gi, power_user.instruct.enabled ? power_user.instruct.system_prompt : ''); - input = input.replace(/{{instructSystemPromptPrefix}}/gi, power_user.instruct.enabled ? power_user.instruct.system_sequence_prefix : ''); - input = input.replace(/{{instructSystemPromptSuffix}}/gi, power_user.instruct.enabled ? power_user.instruct.system_sequence_suffix : ''); - input = input.replace(/{{(instructInput|instructUserPrefix)}}/gi, power_user.instruct.enabled ? power_user.instruct.input_sequence : ''); - input = input.replace(/{{instructUserSuffix}}/gi, power_user.instruct.enabled ? power_user.instruct.input_suffix : ''); - input = input.replace(/{{(instructOutput|instructAssistantPrefix)}}/gi, power_user.instruct.enabled ? power_user.instruct.output_sequence : ''); - input = input.replace(/{{(instructSeparator|instructAssistantSuffix)}}/gi, power_user.instruct.enabled ? power_user.instruct.output_suffix : ''); - input = input.replace(/{{instructSystemPrefix}}/gi, power_user.instruct.enabled ? power_user.instruct.system_sequence : ''); - input = input.replace(/{{instructSystemSuffix}}/gi, power_user.instruct.enabled ? power_user.instruct.system_suffix : ''); - input = input.replace(/{{(instructFirstOutput|instructFirstAssistantPrefix)}}/gi, power_user.instruct.enabled ? (power_user.instruct.first_output_sequence || power_user.instruct.output_sequence) : ''); - input = input.replace(/{{(instructLastOutput|instructLastAssistantPrefix)}}/gi, power_user.instruct.enabled ? (power_user.instruct.last_output_sequence || power_user.instruct.output_sequence) : ''); - input = input.replace(/{{instructStop}}/gi, power_user.instruct.enabled ? power_user.instruct.stop_sequence : ''); - input = input.replace(/{{instructUserFiller}}/gi, power_user.instruct.enabled ? power_user.instruct.user_alignment_message : ''); input = input.replace(/{{exampleSeparator}}/gi, power_user.context.example_separator); input = input.replace(/{{chatStart}}/gi, power_user.context.chat_start); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index bc9cb0ca6..6ef84bbf6 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -204,6 +204,7 @@ let power_user = { output_suffix: '', system_sequence: '', system_suffix: '', + last_system_sequence: '', first_output_sequence: '', last_output_sequence: '', system_sequence_prefix: '', diff --git a/public/scripts/templates/macros.html b/public/scripts/templates/macros.html index a0f18ab9d..f3291333f 100644 --- a/public/scripts/templates/macros.html +++ b/public/scripts/templates/macros.html @@ -60,6 +60,7 @@
  • {{instructLastAssistantPrefix}} – instruct assistant last output sequence
  • {{instructSystemPrefix}} – instruct system message prefix sequence
  • {{instructSystemSuffix}} – instruct system message suffix sequence
  • +
  • {{instructSystemInstructionPrefix}} – instruct system instruction prefix
  • {{instructUserFiller}} – instruct first user message filler
  • {{instructStop}} – instruct stop sequence