Add quiet args to /instruct and /model
| @@ -8522,7 +8522,7 @@ async function selectContextCallback(_, name) { | |||
| 8522 | return foundName; | 8522 | return foundName; |
| 8523 | } | 8523 | } |
| 8524 | 8524 | ||
| 8525 | async function selectInstructCallback(_, name) { | 8525 | async function selectInstructCallback(args, name) { |
| 8526 | if (!name) { | 8526 | if (!name) { |
| 8527 | return power_user.instruct.preset; | 8527 | return power_user.instruct.preset; |
| 8528 | } | 8528 | } |
| @@ -8536,8 +8536,9 @@ async function selectInstructCallback(_, name) { | |||
| 8536 | return ''; | 8536 | return ''; |
| 8537 | } | 8537 | } |
| 8538 | 8538 | ||
| 8539 | const quiet = isTrueBoolean(args?.quiet); | ||
| 8539 | const foundName = result[0].item; | 8540 | const foundName = result[0].item; |
| 8540 | selectInstructPreset(foundName); | 8541 | selectInstructPreset(foundName, quiet); |
| 8541 | return foundName; | 8542 | return foundName; |
| 8542 | } | 8543 | } |
| 8543 | 8544 | ||
| @@ -9216,6 +9217,15 @@ jQuery(async function () { | |||
| 9216 | name: 'instruct', | 9217 | name: 'instruct', |
| 9217 | callback: selectInstructCallback, | 9218 | callback: selectInstructCallback, |
| 9218 | returns: 'current template', | 9219 | returns: 'current template', |
| 9220 | namedArgumentList: [ | ||
| 9221 | SlashCommandNamedArgument.fromProps({ | ||
| 9222 | name: 'quiet', | ||
| 9223 | description: 'Suppress the toast message on template change', | ||
| 9224 | typeList: [ARGUMENT_TYPE.BOOLEAN], | ||
| 9225 | defaultValue: 'false', | ||
| 9226 | enumList: commonEnumProviders.boolean('trueFalse')(), | ||
| 9227 | }), | ||
| 9228 | ], | ||
| 9219 | unnamedArgumentList: [ | 9229 | unnamedArgumentList: [ |
| 9220 | SlashCommandArgument.fromProps({ | 9230 | SlashCommandArgument.fromProps({ |
| 9221 | description: 'instruct template name', | 9231 | description: 'instruct template name', |
| @@ -151,19 +151,20 @@ export function selectContextPreset(preset) { | |||
| 151 | /** | 151 | /** |
| 152 | * Select instruct preset if not already selected. | 152 | * Select instruct preset if not already selected. |
| 153 | * @param {string} preset Preset name. | 153 | * @param {string} preset Preset name. |
| 154 | * @param {boolean} quiet Suppress info message. | ||
| 154 | */ | 155 | */ |
| 155 | export function selectInstructPreset(preset) { | 156 | export function selectInstructPreset(preset, quiet) { |
| 156 | // If instruct preset is not already selected, select it | 157 | // If instruct preset is not already selected, select it |
| 157 | if (preset !== power_user.instruct.preset) { | 158 | if (preset !== power_user.instruct.preset) { |
| 158 | $('#instruct_presets').val(preset).trigger('change'); | 159 | $('#instruct_presets').val(preset).trigger('change'); |
| 159 | toastr.info(`Instruct Mode: template "${preset}" auto-selected`); | 160 | !quiet && toastr.info(`Instruct Mode: template "${preset}" auto-selected`); |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | // If instruct mode is disabled, enable it | 163 | // If instruct mode is disabled, enable it |
| 163 | if (!power_user.instruct.enabled) { | 164 | if (!power_user.instruct.enabled) { |
| 164 | power_user.instruct.enabled = true; | 165 | power_user.instruct.enabled = true; |
| 165 | $('#instruct_enabled').prop('checked', true).trigger('change'); | 166 | $('#instruct_enabled').prop('checked', true).trigger('change'); |
| 166 | toastr.info('Instruct Mode enabled'); | 167 | !quiet && toastr.info('Instruct Mode enabled'); |
| 167 | } | 168 | } |
| 168 | 169 | ||
| 169 | saveSettingsDebounced(); | 170 | saveSettingsDebounced(); |
| @@ -1477,6 +1477,15 @@ export function initDefaultSlashCommands() { | |||
| 1477 | name: 'model', | 1477 | name: 'model', |
| 1478 | callback: modelCallback, | 1478 | callback: modelCallback, |
| 1479 | returns: 'current model', | 1479 | returns: 'current model', |
| 1480 | namedArgumentList: [ | ||
| 1481 | SlashCommandNamedArgument.fromProps({ | ||
| 1482 | name: 'quiet', | ||
| 1483 | description: 'suppress the toast message on model change', | ||
| 1484 | typeList: [ARGUMENT_TYPE.BOOLEAN], | ||
| 1485 | defaultValue: 'false', | ||
| 1486 | enumList: commonEnumProviders.boolean('trueFalse')(), | ||
| 1487 | }), | ||
| 1488 | ], | ||
| 1480 | unnamedArgumentList: [ | 1489 | unnamedArgumentList: [ |
| 1481 | SlashCommandArgument.fromProps({ | 1490 | SlashCommandArgument.fromProps({ |
| 1482 | description: 'model name', | 1491 | description: 'model name', |
| @@ -3382,11 +3391,11 @@ function getModelOptions() { | |||
| 3382 | 3391 | ||
| 3383 | /** | 3392 | /** |
| 3384 | * Sets a model for the current API. | 3393 | * Sets a model for the current API. |
| 3385 | * @param {object} _ Unused | 3394 | * @param {object} args Named arguments |
| 3386 | * @param {string} model New model name | 3395 | * @param {string} model New model name |
| 3387 | * @returns {string} New or existing model name | 3396 | * @returns {string} New or existing model name |
| 3388 | */ | 3397 | */ |
| 3389 | function modelCallback(_, model) { | 3398 | function modelCallback(args, model) { |
| 3390 | const { control: modelSelectControl, options } = getModelOptions(); | 3399 | const { control: modelSelectControl, options } = getModelOptions(); |
| 3391 | 3400 | ||
| 3392 | // If no model was found, the reason was already logged, we just return here | 3401 | // If no model was found, the reason was already logged, we just return here |
| @@ -3426,7 +3435,8 @@ function modelCallback(_, model) { | |||
| 3426 | if (newSelectedOption) { | 3435 | if (newSelectedOption) { |
| 3427 | modelSelectControl.value = newSelectedOption.value; | 3436 | modelSelectControl.value = newSelectedOption.value; |
| 3428 | $(modelSelectControl).trigger('change'); | 3437 | $(modelSelectControl).trigger('change'); |
| 3429 | toastr.success(`Model set to "${newSelectedOption.text}"`); | 3438 | const quiet = isTrueBoolean(args?.quiet); |
| 3439 | !quiet && toastr.success(`Model set to "${newSelectedOption.text}"`); | ||
| 3430 | return newSelectedOption.value; | 3440 | return newSelectedOption.value; |
| 3431 | } else { | 3441 | } else { |
| 3432 | toastr.warning(`No model found with name "${model}"`); | 3442 | toastr.warning(`No model found with name "${model}"`); |