mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add instruct last system sequence
This commit is contained in:
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Adventure"
|
"name": "Adventure"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "\n\n",
|
"system_suffix": "\n\n",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Alpaca-Roleplay"
|
"name": "Alpaca-Roleplay"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Alpaca-Single-Turn"
|
"name": "Alpaca-Single-Turn"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "\n\n",
|
"system_suffix": "\n\n",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Alpaca"
|
"name": "Alpaca"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "<|im_end|>\n",
|
"system_suffix": "<|im_end|>\n",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "ChatML"
|
"name": "ChatML"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "DreamGen Role-Play V1"
|
"name": "DreamGen Role-Play V1"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Koala"
|
"name": "Koala"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Libra-32B"
|
"name": "Libra-32B"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Lightning 1.1"
|
"name": "Lightning 1.1"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
|
"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": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Llama 2 Chat"
|
"name": "Llama 2 Chat"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Metharme"
|
"name": "Metharme"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
|
"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": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Mistral"
|
"name": "Mistral"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "OpenOrca-OpenChat"
|
"name": "OpenOrca-OpenChat"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Pygmalion"
|
"name": "Pygmalion"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Story"
|
"name": "Story"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "\n",
|
"system_suffix": "\n",
|
||||||
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
|
"user_alignment_message": "Let's get started. Please respond based on the information and instructions provided above.",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Synthia"
|
"name": "Synthia"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Vicuna 1.0"
|
"name": "Vicuna 1.0"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "Vicuna 1.1"
|
"name": "Vicuna 1.1"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": true,
|
"system_same_as_user": true,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "WizardLM-13B"
|
"name": "WizardLM-13B"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "WizardLM"
|
"name": "WizardLM"
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"system_suffix": "",
|
"system_suffix": "",
|
||||||
"user_alignment_message": "",
|
"user_alignment_message": "",
|
||||||
"system_same_as_user": false,
|
"system_same_as_user": false,
|
||||||
|
"last_system_sequence": "",
|
||||||
"name": "simple-proxy-for-tavern"
|
"name": "simple-proxy-for-tavern"
|
||||||
}
|
}
|
||||||
|
@ -3034,12 +3034,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="flex1" title="Will be inserted at the start of the chat history if it doesn't start with a User message.">
|
<div class="flex1" title="Will be inserted as a last prompt line when using system/neutral generation.">
|
||||||
<label for="instruct_user_alignment_message">
|
<label for="instruct_last_system_sequence">
|
||||||
<small data-i18n="User Filler Message">User Filler Message</small>
|
<small data-i18n="System Instruction Prefix">System Instruction Prefix</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1" title="If a stop sequence is generated, everything past it will be removed from the output (inclusive).">
|
<div class="flex1" title="If a stop sequence is generated, everything past it will be removed from the output (inclusive).">
|
||||||
@ -3051,6 +3051,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex1" title="Will be inserted at the start of the chat history if it doesn't start with a User message.">
|
||||||
|
<label for="instruct_user_alignment_message">
|
||||||
|
<small data-i18n="User Filler Message">User Filler Message</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,6 +26,7 @@ const controls = [
|
|||||||
{ id: 'instruct_output_suffix', property: 'output_suffix', isCheckbox: false },
|
{ id: 'instruct_output_suffix', property: 'output_suffix', isCheckbox: false },
|
||||||
{ id: 'instruct_system_sequence', property: 'system_sequence', isCheckbox: false },
|
{ id: 'instruct_system_sequence', property: 'system_sequence', isCheckbox: false },
|
||||||
{ id: 'instruct_system_suffix', property: 'system_suffix', 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_user_alignment_message', property: 'user_alignment_message', isCheckbox: false },
|
||||||
{ id: 'instruct_stop_sequence', property: 'stop_sequence', isCheckbox: false },
|
{ id: 'instruct_stop_sequence', property: 'stop_sequence', isCheckbox: false },
|
||||||
{ id: 'instruct_names', property: 'names', isCheckbox: true },
|
{ id: 'instruct_names', property: 'names', isCheckbox: true },
|
||||||
@ -56,6 +57,7 @@ function migrateInstructModeSettings(settings) {
|
|||||||
system_sequence: '',
|
system_sequence: '',
|
||||||
system_suffix: '',
|
system_suffix: '',
|
||||||
user_alignment_message: '',
|
user_alignment_message: '',
|
||||||
|
last_system_sequence: '',
|
||||||
names_force_groups: true,
|
names_force_groups: true,
|
||||||
skip_examples: false,
|
skip_examples: false,
|
||||||
system_same_as_user: 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 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 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 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);
|
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;
|
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) {
|
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
|
// Quiet in-character prompt
|
||||||
@ -517,20 +521,28 @@ export function replaceInstructMacros(input) {
|
|||||||
if (!input) {
|
if (!input) {
|
||||||
return '';
|
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(/{{exampleSeparator}}/gi, power_user.context.example_separator);
|
||||||
input = input.replace(/{{chatStart}}/gi, power_user.context.chat_start);
|
input = input.replace(/{{chatStart}}/gi, power_user.context.chat_start);
|
||||||
|
|
||||||
|
@ -204,6 +204,7 @@ let power_user = {
|
|||||||
output_suffix: '',
|
output_suffix: '',
|
||||||
system_sequence: '',
|
system_sequence: '',
|
||||||
system_suffix: '',
|
system_suffix: '',
|
||||||
|
last_system_sequence: '',
|
||||||
first_output_sequence: '',
|
first_output_sequence: '',
|
||||||
last_output_sequence: '',
|
last_output_sequence: '',
|
||||||
system_sequence_prefix: '',
|
system_sequence_prefix: '',
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
<li><tt>{{instructLastAssistantPrefix}}</tt> – instruct assistant last output sequence</li>
|
<li><tt>{{instructLastAssistantPrefix}}</tt> – instruct assistant last output sequence</li>
|
||||||
<li><tt>{{instructSystemPrefix}}</tt> – instruct system message prefix sequence</li>
|
<li><tt>{{instructSystemPrefix}}</tt> – instruct system message prefix sequence</li>
|
||||||
<li><tt>{{instructSystemSuffix}}</tt> – instruct system message suffix sequence</li>
|
<li><tt>{{instructSystemSuffix}}</tt> – instruct system message suffix sequence</li>
|
||||||
|
<li><tt>{{instructSystemInstructionPrefix}}</tt> – instruct system instruction prefix</li>
|
||||||
<li><tt>{{instructUserFiller}}</tt> – instruct first user message filler</li>
|
<li><tt>{{instructUserFiller}}</tt> – instruct first user message filler</li>
|
||||||
<li><tt>{{instructStop}}</tt> – instruct stop sequence</li>
|
<li><tt>{{instructStop}}</tt> – instruct stop sequence</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Reference in New Issue
Block a user