Instruct "Bind to context" is now an option

This commit is contained in:
Cohee 2023-12-21 15:12:30 +02:00
parent ee75adbd2d
commit dd661cf879
4 changed files with 25 additions and 11 deletions

View File

@ -2380,11 +2380,15 @@
<span class="fa-solid fa-circle-question note-link-span"></span>
</a>
</h4>
<div>
<label for="instruct_enabled" class="checkbox_label">
<div class="flex-container">
<label for="instruct_enabled" class="checkbox_label flex1">
<input id="instruct_enabled" type="checkbox" />
<span data-i18n="Enabled">Enabled</span>
</label>
<label for="instruct_bind_to_context" class="checkbox_label flex1" title="If enabled, Context templates will be automatically selected based on selected Instruct template name or by preference.">
<input id="instruct_bind_to_context" type="checkbox" />
<span data-i18n="Bind to Context">Bind to Context</span>
</label>
</div>
<label for="instruct_presets">
<span data-i18n="Presets">Presets</span>

View File

@ -29,6 +29,7 @@ const controls = [
{ 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 },
{ id: 'instruct_bind_to_context', property: 'bind_to_context', isCheckbox: true },
];
/**
@ -409,6 +410,10 @@ jQuery(() => {
});
$('#instruct_enabled').on('change', function () {
if (!power_user.instruct.bind_to_context) {
return;
}
// When instruct mode gets enabled, select context template matching selected instruct preset
if (power_user.instruct.enabled) {
selectMatchingContextTemplate(power_user.instruct.preset);
@ -440,8 +445,10 @@ jQuery(() => {
}
});
// Select matching context template
selectMatchingContextTemplate(name);
if (power_user.instruct.bind_to_context) {
// Select matching context template
selectMatchingContextTemplate(name);
}
highlightDefaultPreset();
});

View File

@ -205,6 +205,7 @@ let power_user = {
names: false,
names_force_groups: true,
activation_regex: '',
bind_to_context: false,
},
default_context: 'Default',
@ -1718,17 +1719,18 @@ function loadContextSettings() {
}
});
// Select matching instruct preset
for (const instruct_preset of instruct_presets) {
// If instruct preset matches the context template
if (instruct_preset.name === name) {
selectInstructPreset(instruct_preset.name);
break;
if (power_user.instruct.bind_to_context) {
// Select matching instruct preset
for (const instruct_preset of instruct_presets) {
// If instruct preset matches the context template
if (instruct_preset.name === name) {
selectInstructPreset(instruct_preset.name);
break;
}
}
}
highlightDefaultContext();
saveSettingsDebounced();
});

View File

@ -303,6 +303,7 @@ class PresetManager {
'model_novel',
'streaming_kobold',
'enabled',
'bind_to_context',
'seed',
'legacy_api',
'mancer_model',