diff --git a/public/index.html b/public/index.html index d3f386242..166b18071 100644 --- a/public/index.html +++ b/public/index.html @@ -2097,14 +2097,14 @@ - +
- +
@@ -2112,7 +2112,7 @@ Chat Start
- +
@@ -2182,7 +2182,7 @@ Input Sequence
- +
@@ -2190,33 +2190,53 @@ Output Sequence
- + +
+
+ +
+
+ +
+
- +
- +
+
+ +
+ +
+
+
+
- +
@@ -2224,7 +2244,7 @@ Separator
- +
diff --git a/public/instruct/Llama 2 Chat.json b/public/instruct/Llama 2 Chat.json index f7d035277..3a80f3ae8 100644 --- a/public/instruct/Llama 2 Chat.json +++ b/public/instruct/Llama 2 Chat.json @@ -3,8 +3,10 @@ "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "[INST] ", "output_sequence": " [/INST] ", + "first_output_sequence": "[/INST] ", "last_output_sequence": "", - "system_sequence": "[INST] <>\n{{sys}}\n<>\n", + "system_sequence": "[INST] <>\n", + "system_sequence_suffix": "\n<>\n", "stop_sequence": "", "separator_sequence": "\n", "wrap": false, diff --git a/public/script.js b/public/script.js index 2b10506b8..ec3cbc3c7 100644 --- a/public/script.js +++ b/public/script.js @@ -2431,6 +2431,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, false); + if (j === 0 && isInstruct) { + // Reformat with the first output line (if any) + chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct, true); + } + // Do not suffix the message for continuation if (i === 0 && isContinue) { if (isInstruct) { diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 9d60d68e8..2ee82bb70 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -17,6 +17,7 @@ const controls = [ { id: "instruct_wrap", property: "wrap", isCheckbox: true }, { id: "instruct_system_prompt", property: "system_prompt", isCheckbox: false }, { id: "instruct_system_sequence", property: "system_sequence", isCheckbox: false }, + { id: "instruct_system_sequence_suffix", property: "system_sequence_suffix", isCheckbox: false }, { id: "instruct_separator_sequence", property: "separator_sequence", isCheckbox: false }, { id: "instruct_input_sequence", property: "input_sequence", isCheckbox: false }, { id: "instruct_output_sequence", property: "output_sequence", isCheckbox: false }, @@ -24,6 +25,7 @@ const controls = [ { id: "instruct_names", property: "names", isCheckbox: true }, { id: "instruct_macro", property: "macro", isCheckbox: true }, { id: "instruct_names_force_groups", property: "names_force_groups", isCheckbox: true }, + { id: "instruct_first_output_sequence", property: "first_output_sequence", isCheckbox: false }, { id: "instruct_last_output_sequence", property: "last_output_sequence", isCheckbox: false }, { id: "instruct_activation_regex", property: "activation_regex", isCheckbox: false }, ]; @@ -200,9 +202,10 @@ export function getInstructStoppingSequences() { if (power_user.instruct.enabled) { const input_sequence = power_user.instruct.input_sequence; const output_sequence = power_user.instruct.output_sequence; + const first_output_sequence = power_user.instruct.first_output_sequence; const last_output_sequence = power_user.instruct.last_output_sequence; - const combined_sequence = `${input_sequence}\n${output_sequence}\n${last_output_sequence}`; + const combined_sequence = `${input_sequence}\n${output_sequence}\n${first_output_sequence}\n${last_output_sequence}`; combined_sequence.split('\n').filter((line, index, self) => self.indexOf(line) === index).forEach(addInstructSequence); } @@ -231,8 +234,12 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata let sequence = (isUser || isNarrator) ? power_user.instruct.input_sequence : power_user.instruct.output_sequence; - if (sequence === power_user.instruct.output_sequence && forceLastOutputSequence && power_user.instruct.last_output_sequence) { - sequence = power_user.instruct.last_output_sequence; + if (forceLastOutputSequence) { + if (sequence === power_user.instruct.output_sequence && power_user.instruct.first_output_sequence) { + sequence = power_user.instruct.first_output_sequence; + } else if (sequence === power_user.instruct.output_sequence && power_user.instruct.last_output_sequence) { + sequence = power_user.instruct.last_output_sequence; + } } if (power_user.instruct.macro) { @@ -254,14 +261,14 @@ export function formatInstructModeChat(name, mes, isUser, isNarrator, forceAvata * @returns {string} Formatted instruct mode system prompt. */ export function formatInstructModeSystemPrompt(systemPrompt){ - if (power_user.instruct.system_sequence) { - const separator = power_user.instruct.wrap ? '\n' : ''; + const separator = power_user.instruct.wrap ? '\n' : ''; - if (power_user.instruct.system_sequence.includes("{{sys}}")) { - return power_user.instruct.system_sequence.replace(/{{sys}}/gi, systemPrompt); - } else { - return power_user.instruct.system_sequence + separator + systemPrompt; - } + if (power_user.instruct.system_sequence) { + systemPrompt = power_user.instruct.system_sequence + separator + systemPrompt; + } + + if (power_user.instruct.system_sequence_suffix) { + systemPrompt = systemPrompt + separator + power_user.instruct.system_sequence_suffix; } return systemPrompt; diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 9ab1d964d..b50d2aef2 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -163,9 +163,11 @@ let power_user = { names: false, system_prompt: "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}. Write 1 reply only.", system_sequence: '', + system_sequence_suffix: '', stop_sequence: '', input_sequence: '### Instruction:', output_sequence: '### Response:', + first_output_sequence: '', last_output_sequence: '', preset: 'Alpaca', separator_sequence: '',