mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 03:17:54 +01:00
(WIP) Add new instruct mode sequences. Deprecates separator sequence.
1. Separate suffixes for all roles 2. System message sequences 3. User alignment message
This commit is contained in:
parent
01d17f4396
commit
8b7b32a141
@ -2869,36 +2869,99 @@
|
|||||||
<div class="fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
|
<div class="fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-drawer-content">
|
<div class="inline-drawer-content">
|
||||||
|
<h5 class="textAlignCenter" data-i18n="Chat Messages Wrapping">
|
||||||
|
Chat Messages Wrapping
|
||||||
|
</h5>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="flex1">
|
<div class="flex1" title="Inserted before a User message and as a last prompt line when impersonating.">
|
||||||
<label for="instruct_input_sequence">
|
<label for="instruct_input_sequence">
|
||||||
<small data-i18n="Input Sequence">Input Sequence</small>
|
<small data-i18n="User Message Prefix">User Message Prefix</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1" title="Inserted after a User message.">
|
||||||
|
<label for="instruct_input_suffix">
|
||||||
|
<small data-i18n="User Message Suffix">User Message Suffix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex1" title="Inserted before an Assistant message and as a last prompt line when generating an AI reply.">
|
||||||
<label for="instruct_output_sequence">
|
<label for="instruct_output_sequence">
|
||||||
<small data-i18n="Output Sequence">Output Sequence</small>
|
<small data-i18n="Assistant Message Prefix">Assistant Message Prefix</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex1" title="Inserted after an Assistant message.">
|
||||||
|
<label for="instruct_output_suffix">
|
||||||
|
<small data-i18n="Assistant Message Suffix">Assistant Message Suffix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="flex1">
|
<div class="flex1" title="Inserted before a System (added by slash commands or extensions) message and as a last prompt line when generating a neutral/system reply. Defaults to User Prefix if not defined.">
|
||||||
|
<label for="instruct_system_sequence">
|
||||||
|
<small data-i18n="System Message Prefix">System Message Prefix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex1" title="Inserted after a System message. Defaults to User Suffix if not defined.">
|
||||||
|
<label for="instruct_system_suffix">
|
||||||
|
<small data-i18n="System Message Suffix">System Message Suffix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h5 class="textAlignCenter" data-i18n="System Prompt Wrapping">
|
||||||
|
System Prompt Wrapping
|
||||||
|
</h5>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex1" title="Inserted before a System prompt.">
|
||||||
|
<label for="instruct_system_sequence_prefix">
|
||||||
|
<small data-i18n="System Prompt Prefix">System Prompt Prefix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex1" title="Inserted after a System prompt.">
|
||||||
|
<label for="instruct_system_sequence_suffix">
|
||||||
|
<small data-i18n="System Prompt Suffix">System Prompt Suffix</small>
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
<textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h5 class="textAlignCenter" data-i18n="Misc. Sequences">
|
||||||
|
Misc. Sequences
|
||||||
|
</h5>
|
||||||
|
<div class="flex-container">
|
||||||
|
<div class="flex1" title="Inserted before the first Assistant's message.">
|
||||||
<label for="instruct_first_output_sequence">
|
<label for="instruct_first_output_sequence">
|
||||||
<small data-i18n="First Output Sequence">First Output Sequence</small>
|
<small data-i18n="First Output Prefix">First Output Prefix</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1" title="Inserted after the last Assistant's message.">
|
||||||
<label for="instruct_last_output_sequence">
|
<label for="instruct_last_output_sequence">
|
||||||
<small data-i18n="Last Output Sequence">Last Output Sequence</small>
|
<small data-i18n="Last Output Prefix">Last Output Prefix</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
@ -2906,25 +2969,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div class="flex1">
|
<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_system_sequence_prefix">
|
<label for="instruct_user_alignment_message">
|
||||||
<small data-i18n="System Sequence Prefix">System Sequence Prefix</small>
|
<small data-i18n="User Alignment Message">User Alignment Message</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1" title="If a stop sequence is generated, everything past it will be removed (inclusive).">
|
||||||
<label for="instruct_system_sequence_suffix">
|
|
||||||
<small data-i18n="System Sequence Suffix">System Sequence Suffix</small>
|
|
||||||
</label>
|
|
||||||
<div>
|
|
||||||
<textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-container">
|
|
||||||
<div class="flex1">
|
|
||||||
<label for="instruct_stop_sequence">
|
<label for="instruct_stop_sequence">
|
||||||
<small data-i18n="Stop Sequence">Stop Sequence</small>
|
<small data-i18n="Stop Sequence">Stop Sequence</small>
|
||||||
</label>
|
</label>
|
||||||
@ -2932,14 +2985,6 @@
|
|||||||
<textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
<textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
|
||||||
<label for="instruct_separator_sequence">
|
|
||||||
<small data-i18n="Separator">Separator</small>
|
|
||||||
</label>
|
|
||||||
<div>
|
|
||||||
<textarea id="instruct_separator_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="—" rows="1"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,9 +19,13 @@ const controls = [
|
|||||||
{ id: 'instruct_system_prompt', property: 'system_prompt', isCheckbox: false },
|
{ id: 'instruct_system_prompt', property: 'system_prompt', isCheckbox: false },
|
||||||
{ id: 'instruct_system_sequence_prefix', property: 'system_sequence_prefix', isCheckbox: false },
|
{ id: 'instruct_system_sequence_prefix', property: 'system_sequence_prefix', isCheckbox: false },
|
||||||
{ id: 'instruct_system_sequence_suffix', property: 'system_sequence_suffix', 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_input_sequence', property: 'input_sequence', isCheckbox: false },
|
||||||
|
{ id: 'instruct_input_suffix', property: 'input_suffix', isCheckbox: false },
|
||||||
{ id: 'instruct_output_sequence', property: 'output_sequence', isCheckbox: false },
|
{ id: 'instruct_output_sequence', property: 'output_sequence', isCheckbox: false },
|
||||||
|
{ 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_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 },
|
||||||
{ id: 'instruct_macro', property: 'macro', isCheckbox: true },
|
{ id: 'instruct_macro', property: 'macro', isCheckbox: true },
|
||||||
@ -33,6 +37,46 @@ const controls = [
|
|||||||
{ id: 'instruct_skip_examples', property: 'skip_examples', isCheckbox: true },
|
{ id: 'instruct_skip_examples', property: 'skip_examples', isCheckbox: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrates instruct mode settings into the evergreen format.
|
||||||
|
* @param {object} settings Instruct mode settings.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function migrateInstructModeSettings(settings) {
|
||||||
|
// Separator sequence => Output suffix
|
||||||
|
if (settings.separator_sequence === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.output_suffix = settings.separator_sequence || '';
|
||||||
|
delete settings.separator_sequence;
|
||||||
|
|
||||||
|
// Init the rest with default values
|
||||||
|
if (settings.input_suffix === undefined) {
|
||||||
|
settings.input_suffix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.system_sequence === undefined) {
|
||||||
|
settings.system_sequence = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.system_suffix === undefined) {
|
||||||
|
settings.system_suffix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.user_alignment_message === undefined) {
|
||||||
|
settings.user_alignment_message = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.names_force_groups === undefined) {
|
||||||
|
settings.names_force_groups = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.skip_examples === undefined) {
|
||||||
|
settings.skip_examples = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads instruct mode settings from the given data object.
|
* Loads instruct mode settings from the given data object.
|
||||||
* @param {object} data Settings data object.
|
* @param {object} data Settings data object.
|
||||||
@ -42,13 +86,7 @@ export function loadInstructMode(data) {
|
|||||||
instruct_presets = data.instruct;
|
instruct_presets = data.instruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (power_user.instruct.names_force_groups === undefined) {
|
migrateInstructModeSettings(power_user.instruct);
|
||||||
power_user.instruct.names_force_groups = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (power_user.instruct.skip_examples === undefined) {
|
|
||||||
power_user.instruct.skip_examples = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
controls.forEach(control => {
|
controls.forEach(control => {
|
||||||
const $element = $(`#${control.id}`);
|
const $element = $(`#${control.id}`);
|
||||||
@ -442,6 +480,8 @@ jQuery(() => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrateInstructModeSettings(preset);
|
||||||
|
|
||||||
power_user.instruct.preset = String(name);
|
power_user.instruct.preset = String(name);
|
||||||
controls.forEach(control => {
|
controls.forEach(control => {
|
||||||
if (preset[control.property] !== undefined) {
|
if (preset[control.property] !== undefined) {
|
||||||
|
@ -197,19 +197,25 @@ let power_user = {
|
|||||||
preset: 'Alpaca',
|
preset: 'Alpaca',
|
||||||
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}}.\n',
|
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}}.\n',
|
||||||
input_sequence: '### Instruction:',
|
input_sequence: '### Instruction:',
|
||||||
|
input_suffix: '',
|
||||||
output_sequence: '### Response:',
|
output_sequence: '### Response:',
|
||||||
|
output_suffix: '',
|
||||||
|
system_sequence: '',
|
||||||
|
system_suffix: '',
|
||||||
first_output_sequence: '',
|
first_output_sequence: '',
|
||||||
last_output_sequence: '',
|
last_output_sequence: '',
|
||||||
system_sequence_prefix: '',
|
system_sequence_prefix: '',
|
||||||
system_sequence_suffix: '',
|
system_sequence_suffix: '',
|
||||||
stop_sequence: '',
|
stop_sequence: '',
|
||||||
separator_sequence: '',
|
|
||||||
wrap: true,
|
wrap: true,
|
||||||
macro: true,
|
macro: true,
|
||||||
names: false,
|
names: false,
|
||||||
names_force_groups: true,
|
names_force_groups: true,
|
||||||
activation_regex: '',
|
activation_regex: '',
|
||||||
bind_to_context: false,
|
bind_to_context: false,
|
||||||
|
user_alignment_message: '',
|
||||||
|
/** @deprecated Use output_suffix instead */
|
||||||
|
separator_sequence: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
default_context: 'Default',
|
default_context: 'Default',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user