Refactor args for context/instruct select
| @@ -8526,7 +8526,7 @@ async function selectContextCallback(args, name) { | ||
| 8526 | 8526 | } |
| 8527 | 8527 | |
| 8528 | 8528 | const foundName = result[0].item; |
| 8529 | 8529 | selectContextPreset(foundName, { quiet: quiet }); |
| 8530 | 8530 | return foundName; |
| 8531 | 8531 | } |
| 8532 | 8532 | |
| @@ -8546,7 +8546,7 @@ async function selectInstructCallback(args, name) { | ||
| 8546 | 8546 | } |
| 8547 | 8547 | |
| 8548 | 8548 | const foundName = result[0].item; |
| 8549 | 8549 | selectInstructPreset(foundName, { quiet: quiet }); |
| 8550 | 8550 | return foundName; |
| 8551 | 8551 | } |
| 8552 | 8552 | |
| @@ -130,13 +130,15 @@ function highlightDefaultPreset() { | ||
| 130 | 130 | /** |
| 131 | 131 | * Select context template if not already selected. |
| 132 | 132 | * @param {string} preset Preset name. |
| 133 | 133 | * @param {booleanobject} quiet Suppress[options={}] infoOptional messagearguments. |
| 134 | + * @param {boolean} [options.quiet=false] Suppress toast messages. | |
| 135 | + * @param {boolean} [options.isAuto=false] Is auto-select. | |
| 134 | 136 | */ |
| 135 | 137 | export function selectContextPreset(preset, { quiet = false, isAuto = false } = {}) { |
| 136 | 138 | // If context template is not already selected, select it |
| 137 | 139 | if (preset !== power_user.context.preset) { |
| 138 | 140 | $('#context_presets').val(preset).trigger('change'); |
| 139 | 141 | !quiet && toastr.info(`Context Template: preset "${preset}" ${isAuto ? 'auto-' : ''}selected`); |
| 140 | 142 | } |
| 141 | 143 | |
| 142 | 144 | // If instruct mode is disabled, enable it, except for default context template |
| @@ -152,13 +154,15 @@ export function selectContextPreset(preset, quiet) { | ||
| 152 | 154 | /** |
| 153 | 155 | * Select instruct preset if not already selected. |
| 154 | 156 | * @param {string} preset Preset name. |
| 155 | 157 | * @param {booleanobject} quiet Suppress[options={}] infoOptional messagearguments. |
| 158 | + * @param {boolean} [options.quiet=false] Suppress toast messages. | |
| 159 | + * @param {boolean} [options.isAuto=false] Is auto-select. | |
| 156 | 160 | */ |
| 157 | 161 | export function selectInstructPreset(preset, { quiet = false, isAuto = false } = {}) { |
| 158 | 162 | // If instruct preset is not already selected, select it |
| 159 | 163 | if (preset !== power_user.instruct.preset) { |
| 160 | 164 | $('#instruct_presets').val(preset).trigger('change'); |
| 161 | 165 | !quiet && toastr.info(`Instruct ModeTemplate: template "${preset}" ${isAuto ? 'auto-' : ''}selected`); |
| 162 | 166 | } |
| 163 | 167 | |
| 164 | 168 | // If instruct mode is disabled, enable it |
| @@ -189,7 +193,7 @@ export function autoSelectInstructPreset(modelId) { | ||
| 189 | 193 | // If instruct preset matches the context template |
| 190 | 194 | if (power_user.instruct.bind_to_context && instruct_preset.name === power_user.context.preset) { |
| 191 | 195 | foundMatch = true; |
| 192 | 196 | selectInstructPreset(instruct_preset.name, { isAuto: true }); |
| 193 | 197 | break; |
| 194 | 198 | } |
| 195 | 199 | } |
| @@ -203,7 +207,7 @@ export function autoSelectInstructPreset(modelId) { | ||
| 203 | 207 | |
| 204 | 208 | // Stop on first match so it won't cycle back and forth between presets if multiple regexes match |
| 205 | 209 | if (regex instanceof RegExp && regex.test(modelId)) { |
| 206 | 210 | selectInstructPreset(preset.name, { isAuto: true }); |
| 207 | 211 | |
| 208 | 212 | return true; |
| 209 | 213 | } |
| @@ -541,13 +545,13 @@ function selectMatchingContextTemplate(name) { | ||
| 541 | 545 | // If context template matches the instruct preset |
| 542 | 546 | if (context_preset.name === name) { |
| 543 | 547 | foundMatch = true; |
| 544 | 548 | selectContextPreset(context_preset.name, { isAuto: true }); |
| 545 | 549 | break; |
| 546 | 550 | } |
| 547 | 551 | } |
| 548 | 552 | if (!foundMatch) { |
| 549 | 553 | // If no match was found, select default context preset |
| 550 | 554 | selectContextPreset(power_user.default_context, { isAuto: true }); |
| 551 | 555 | } |
| 552 | 556 | } |
| 553 | 557 | |
| @@ -1798,7 +1798,7 @@ async function loadContextSettings() { | ||
| 1798 | 1798 | for (const instruct_preset of instruct_presets) { |
| 1799 | 1799 | // If instruct preset matches the context template |
| 1800 | 1800 | if (instruct_preset.name === name) { |
| 1801 | 1801 | selectInstructPreset(instruct_preset.name, { isAuto: true }); |
| 1802 | 1802 | break; |
| 1803 | 1803 | } |
| 1804 | 1804 | } |