mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Don't reset instruct preset when toggling instruct mode
This commit is contained in:
@ -338,6 +338,26 @@ export function formatInstructModePrompt(name, isImpersonate, promptBias, name1,
|
|||||||
return text.trimEnd() + (includeNames ? '' : separator);
|
return text.trimEnd() + (includeNames ? '' : separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select context template matching instruct preset.
|
||||||
|
* @param {string} name Preset name.
|
||||||
|
*/
|
||||||
|
function selectMatchingContextTemplate(name) {
|
||||||
|
let foundMatch = false;
|
||||||
|
for (const context_preset of context_presets) {
|
||||||
|
// If context template matches the instruct preset
|
||||||
|
if (context_preset.name === name) {
|
||||||
|
foundMatch = true;
|
||||||
|
selectContextPreset(context_preset.name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundMatch) {
|
||||||
|
// If no match was found, select default context preset
|
||||||
|
selectContextPreset(power_user.default_context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(() => {
|
jQuery(() => {
|
||||||
$('#instruct_set_default').on('click', function () {
|
$('#instruct_set_default').on('click', function () {
|
||||||
if (power_user.instruct.preset === power_user.default_instruct) {
|
if (power_user.instruct.preset === power_user.default_instruct) {
|
||||||
@ -356,7 +376,7 @@ jQuery(() => {
|
|||||||
$('#instruct_enabled').on('change', function () {
|
$('#instruct_enabled').on('change', function () {
|
||||||
// When instruct mode gets enabled, select context template matching selected instruct preset
|
// When instruct mode gets enabled, select context template matching selected instruct preset
|
||||||
if (power_user.instruct.enabled) {
|
if (power_user.instruct.enabled) {
|
||||||
$('#instruct_presets').trigger('change');
|
selectMatchingContextTemplate(power_user.instruct.preset);
|
||||||
// When instruct mode gets disabled, select default context preset
|
// When instruct mode gets disabled, select default context preset
|
||||||
} else {
|
} else {
|
||||||
selectContextPreset(power_user.default_context);
|
selectContextPreset(power_user.default_context);
|
||||||
@ -364,7 +384,7 @@ jQuery(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#instruct_presets').on('change', function () {
|
$('#instruct_presets').on('change', function () {
|
||||||
const name = $(this).find(':selected').val();
|
const name = String($(this).find(':selected').val());
|
||||||
const preset = instruct_presets.find(x => x.name === name);
|
const preset = instruct_presets.find(x => x.name === name);
|
||||||
|
|
||||||
if (!preset) {
|
if (!preset) {
|
||||||
@ -386,19 +406,7 @@ jQuery(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Select matching context template
|
// Select matching context template
|
||||||
let foundMatch = false;
|
selectMatchingContextTemplate(name);
|
||||||
for (const context_preset of context_presets) {
|
|
||||||
// If context template matches the instruct preset
|
|
||||||
if (context_preset.name === name) {
|
|
||||||
foundMatch = true;
|
|
||||||
selectContextPreset(context_preset.name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!foundMatch) {
|
|
||||||
// If no match was found, select default context preset
|
|
||||||
selectContextPreset(power_user.default_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
highlightDefaultPreset();
|
highlightDefaultPreset();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user