diff --git a/default/content/presets/context/Alpaca-Roleplay.json b/default/content/presets/context/Alpaca-Roleplay.json
index d564a1dd7..e7a45c2d8 100644
--- a/default/content/presets/context/Alpaca-Roleplay.json
+++ b/default/content/presets/context/Alpaca-Roleplay.json
@@ -1,5 +1,5 @@
{
- "story_string": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n\n{{#if system}}{{system}}\n\n{{/if}}### Input:\n{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
+ "story_string": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n\n{{#if system}}{{system}}\n\n{{/if}}### Input:\n{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}\n\n",
"example_separator": "### New Roleplay:",
"chat_start": "### New Roleplay:",
"use_stop_strings": false,
@@ -9,4 +9,4 @@
"include_newline": false,
"single_line": false,
"name": "Alpaca-Roleplay"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/context/Alpaca.json b/default/content/presets/context/Alpaca.json
new file mode 100644
index 000000000..6e9418549
--- /dev/null
+++ b/default/content/presets/context/Alpaca.json
@@ -0,0 +1,12 @@
+{
+ "story_string": "{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}\n\n",
+ "example_separator": "",
+ "chat_start": "",
+ "use_stop_strings": false,
+ "allow_jailbreak": false,
+ "always_force_name2": true,
+ "trim_sentences": false,
+ "include_newline": false,
+ "single_line": false,
+ "name": "Alpaca"
+}
diff --git a/default/content/presets/context/ChatML.json b/default/content/presets/context/ChatML.json
index 80046d170..2184e91d3 100644
--- a/default/content/presets/context/ChatML.json
+++ b/default/content/presets/context/ChatML.json
@@ -1,5 +1,5 @@
{
- "story_string": "<|im_start|>system\n{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}<|im_end|>",
+ "story_string": "<|im_start|>system\n{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}}<|im_end|>",
"example_separator": "",
"chat_start": "",
"use_stop_strings": false,
diff --git a/default/content/presets/context/Llama 2 Chat.json b/default/content/presets/context/Llama 2 Chat.json
new file mode 100644
index 000000000..be18ad69d
--- /dev/null
+++ b/default/content/presets/context/Llama 2 Chat.json
@@ -0,0 +1,12 @@
+{
+ "story_string": "[INST] <>\n{{#if system}}{{system}}\n<>\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST]",
+ "example_separator": "",
+ "chat_start": "",
+ "use_stop_strings": false,
+ "allow_jailbreak": false,
+ "always_force_name2": true,
+ "trim_sentences": false,
+ "include_newline": false,
+ "single_line": false,
+ "name": "Llama 2 Chat"
+}
diff --git a/default/content/presets/context/Mistral.json b/default/content/presets/context/Mistral.json
index d8c437e0e..d9551afe8 100644
--- a/default/content/presets/context/Mistral.json
+++ b/default/content/presets/context/Mistral.json
@@ -1,5 +1,5 @@
{
- "story_string": "[INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}[/INST]",
+ "story_string": "[INST] {{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}} [/INST]",
"example_separator": "Examples:",
"chat_start": "",
"use_stop_strings": false,
@@ -9,4 +9,4 @@
"include_newline": false,
"single_line": false,
"name": "Mistral"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/context/Synthia.json b/default/content/presets/context/Synthia.json
new file mode 100644
index 000000000..8bffe47d3
--- /dev/null
+++ b/default/content/presets/context/Synthia.json
@@ -0,0 +1,12 @@
+{
+ "story_string": "{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}",
+ "example_separator": "",
+ "chat_start": "",
+ "use_stop_strings": false,
+ "allow_jailbreak": false,
+ "always_force_name2": true,
+ "trim_sentences": false,
+ "include_newline": false,
+ "single_line": false,
+ "name": "Synthia"
+}
diff --git a/default/content/presets/instruct/Alpaca-Roleplay.json b/default/content/presets/instruct/Alpaca-Roleplay.json
index 37bf6cae7..5a5054340 100644
--- a/default/content/presets/instruct/Alpaca-Roleplay.json
+++ b/default/content/presets/instruct/Alpaca-Roleplay.json
@@ -1,9 +1,9 @@
{
"system_prompt": "Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.",
- "input_sequence": "\n### Instruction:",
- "output_sequence": "\n### Response:",
- "last_output_sequence": "\n### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):",
- "system_sequence": "",
+ "input_sequence": "### Instruction:",
+ "output_sequence": "### Response:",
+ "last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):",
+ "system_sequence": "### Input:",
"stop_sequence": "",
"wrap": true,
"macro": true,
@@ -14,10 +14,10 @@
"system_sequence_suffix": "",
"first_output_sequence": "",
"skip_examples": false,
- "output_suffix": "",
- "input_suffix": "",
- "system_suffix": "",
+ "output_suffix": "\n\n",
+ "input_suffix": "\n\n",
+ "system_suffix": "\n\n",
"user_alignment_message": "",
- "system_same_as_user": true,
+ "system_same_as_user": false,
"name": "Alpaca-Roleplay"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/instruct/Alpaca.json b/default/content/presets/instruct/Alpaca.json
index f3b3b4cc8..96fd2cc83 100644
--- a/default/content/presets/instruct/Alpaca.json
+++ b/default/content/presets/instruct/Alpaca.json
@@ -3,7 +3,7 @@
"input_sequence": "### Instruction:",
"output_sequence": "### Response:",
"last_output_sequence": "",
- "system_sequence": "",
+ "system_sequence": "### Input:",
"stop_sequence": "",
"wrap": true,
"macro": true,
@@ -14,10 +14,10 @@
"system_sequence_suffix": "",
"first_output_sequence": "",
"skip_examples": false,
- "output_suffix": "",
- "input_suffix": "",
- "system_suffix": "",
+ "output_suffix": "\n\n",
+ "input_suffix": "\n\n",
+ "system_suffix": "\n\n",
"user_alignment_message": "",
- "system_same_as_user": true,
+ "system_same_as_user": false,
"name": "Alpaca"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/instruct/ChatML.json b/default/content/presets/instruct/ChatML.json
index f6bf0aa44..348ae2458 100644
--- a/default/content/presets/instruct/ChatML.json
+++ b/default/content/presets/instruct/ChatML.json
@@ -1,11 +1,11 @@
{
"system_prompt": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.",
- "input_sequence": "\n<|im_start|>user\n",
- "output_sequence": "\n<|im_start|>assistant\n",
+ "input_sequence": "<|im_start|>user",
+ "output_sequence": "<|im_start|>assistant",
"last_output_sequence": "",
- "system_sequence": "\n<|im_start|>system\n",
+ "system_sequence": "<|im_start|>system",
"stop_sequence": "<|im_end|>",
- "wrap": false,
+ "wrap": true,
"macro": true,
"names": true,
"names_force_groups": true,
@@ -14,9 +14,9 @@
"system_sequence_suffix": "",
"first_output_sequence": "",
"skip_examples": false,
- "output_suffix": "<|im_end|>",
- "input_suffix": "<|im_end|>",
- "system_suffix": "<|im_end|>",
+ "output_suffix": "<|im_end|>\n",
+ "input_suffix": "<|im_end|>\n",
+ "system_suffix": "<|im_end|>\n",
"user_alignment_message": "",
"system_same_as_user": false,
"name": "ChatML"
diff --git a/default/content/presets/instruct/Llama 2 Chat.json b/default/content/presets/instruct/Llama 2 Chat.json
index c129e71d1..aeb4e13fd 100644
--- a/default/content/presets/instruct/Llama 2 Chat.json
+++ b/default/content/presets/instruct/Llama 2 Chat.json
@@ -1,7 +1,7 @@
{
"system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.",
"input_sequence": "[INST] ",
- "output_sequence": " ",
+ "output_sequence": "",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
@@ -10,14 +10,14 @@
"names": false,
"names_force_groups": true,
"activation_regex": "",
- "system_sequence_prefix": "[INST] <>\n",
- "system_sequence_suffix": "\n<>\n",
+ "system_sequence_prefix": "",
+ "system_sequence_suffix": "",
"first_output_sequence": "",
"skip_examples": false,
- "output_suffix": " ",
- "input_suffix": " [/INST]",
+ "output_suffix": "\n",
+ "input_suffix": " [/INST]\n",
"system_suffix": "",
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
"system_same_as_user": true,
"name": "Llama 2 Chat"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/instruct/Mistral.json b/default/content/presets/instruct/Mistral.json
index 2dbf47fdc..4f35139fa 100644
--- a/default/content/presets/instruct/Mistral.json
+++ b/default/content/presets/instruct/Mistral.json
@@ -1,7 +1,7 @@
{
"system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.",
"input_sequence": "[INST] ",
- "output_sequence": "\n",
+ "output_sequence": "",
"last_output_sequence": "",
"system_sequence": "",
"stop_sequence": "",
@@ -15,9 +15,9 @@
"first_output_sequence": "",
"skip_examples": false,
"output_suffix": "\n",
- "input_suffix": " [/INST]",
+ "input_suffix": " [/INST]\n",
"system_suffix": "",
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
"system_same_as_user": true,
"name": "Mistral"
-}
\ No newline at end of file
+}
diff --git a/default/content/presets/instruct/Synthia.json b/default/content/presets/instruct/Synthia.json
index 3315c9046..24ec4849e 100644
--- a/default/content/presets/instruct/Synthia.json
+++ b/default/content/presets/instruct/Synthia.json
@@ -1,9 +1,9 @@
{
"system_prompt": "Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.",
- "input_sequence": "\nUSER: ",
- "output_sequence": "\nASSISTANT: ",
+ "input_sequence": "USER: ",
+ "output_sequence": "ASSISTANT: ",
"last_output_sequence": "",
- "system_sequence": "",
+ "system_sequence": "SYSTEM: ",
"stop_sequence": "",
"wrap": false,
"macro": true,
@@ -14,10 +14,10 @@
"system_sequence_suffix": "",
"first_output_sequence": "",
"skip_examples": false,
- "output_suffix": "",
- "input_suffix": "",
- "system_suffix": "",
+ "output_suffix": "\n",
+ "input_suffix": "\n",
+ "system_suffix": "\n",
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
- "system_same_as_user": true,
+ "system_same_as_user": false,
"name": "Synthia"
-}
\ No newline at end of file
+}
diff --git a/public/script.js b/public/script.js
index 04fb0238d..7d1f85bdb 100644
--- a/public/script.js
+++ b/public/script.js
@@ -3505,15 +3505,18 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
console.debug('generating prompt');
chatString = '';
arrMes = arrMes.reverse();
- arrMes.forEach(function (item, i, arr) {// For added anchors and others
+ arrMes.forEach(function (item, i, arr) {
// OAI doesn't need all of this
if (main_api === 'openai') {
return;
}
- // Cohee: I'm not even sure what this is for anymore
+ // Cohee: This removes a newline from the end of the last message in the context
+ // Last prompt line will add a newline if it's not a continuation
if (i === arrMes.length - 1 && type !== 'continue') {
- item = item.replace(/\n?$/, '');
+ if (!isInstruct || power_user.instruct.wrap) {
+ item = item.replace(/\n?$/, '');
+ }
}
mesSend[mesSend.length] = { message: item, extensionPrompts: [] };
diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js
index e646cdd79..48fec1129 100644
--- a/public/scripts/instruct-mode.js
+++ b/public/scripts/instruct-mode.js
@@ -373,7 +373,7 @@ export function formatInstructModeExamples(mesExamplesArray, name1, name2) {
let inputPrefix = power_user.instruct.input_sequence || '';
let outputPrefix = power_user.instruct.output_sequence || '';
- let inputSuffix = power_user.instruct.output_suffix || '';
+ let inputSuffix = power_user.instruct.input_suffix || '';
let outputSuffix = power_user.instruct.output_suffix || '';
if (power_user.instruct.macro) {
diff --git a/public/scripts/macros.js b/public/scripts/macros.js
index 63da09b0c..f3527d451 100644
--- a/public/scripts/macros.js
+++ b/public/scripts/macros.js
@@ -4,6 +4,9 @@ import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
import { replaceInstructMacros } from './instruct-mode.js';
import { replaceVariableMacros } from './variables.js';
+// Register any macro that you want to leave in the compiled story string
+Handlebars.registerHelper('trim', () => '{{trim}}');
+
/**
* Returns the ID of the last message in the chat.
* @returns {string} The ID of the last message in the chat.
@@ -257,6 +260,7 @@ export function evaluateMacros(content, env) {
content = replaceInstructMacros(content);
content = replaceVariableMacros(content);
content = content.replace(/{{newline}}/gi, '\n');
+ content = content.replace(/\n*{{trim}}\n*/gi, '');
content = content.replace(/{{input}}/gi, () => String($('#send_textarea').val()));
// Substitute passed-in variables