diff --git a/public/script.js b/public/script.js index 0228f9811..54e5fecb6 100644 --- a/public/script.js +++ b/public/script.js @@ -8522,7 +8522,7 @@ async function selectContextCallback(_, name) { return foundName; } -async function selectInstructCallback(_, name) { +async function selectInstructCallback(args, name) { if (!name) { return power_user.instruct.preset; } @@ -8536,8 +8536,9 @@ async function selectInstructCallback(_, name) { return ''; } + const quiet = isTrueBoolean(args?.quiet); const foundName = result[0].item; - selectInstructPreset(foundName); + selectInstructPreset(foundName, quiet); return foundName; } @@ -9216,6 +9217,15 @@ jQuery(async function () { name: 'instruct', callback: selectInstructCallback, returns: 'current template', + namedArgumentList: [ + SlashCommandNamedArgument.fromProps({ + name: 'quiet', + description: 'Suppress the toast message on template change', + typeList: [ARGUMENT_TYPE.BOOLEAN], + defaultValue: 'false', + enumList: commonEnumProviders.boolean('trueFalse')(), + }), + ], unnamedArgumentList: [ SlashCommandArgument.fromProps({ description: 'instruct template name', diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 006d570bf..520f1c4f1 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -151,19 +151,20 @@ export function selectContextPreset(preset) { /** * Select instruct preset if not already selected. * @param {string} preset Preset name. + * @param {boolean} quiet Suppress info message. */ -export function selectInstructPreset(preset) { +export function selectInstructPreset(preset, quiet) { // If instruct preset is not already selected, select it if (preset !== power_user.instruct.preset) { $('#instruct_presets').val(preset).trigger('change'); - toastr.info(`Instruct Mode: template "${preset}" auto-selected`); + !quiet && toastr.info(`Instruct Mode: template "${preset}" auto-selected`); } // If instruct mode is disabled, enable it if (!power_user.instruct.enabled) { power_user.instruct.enabled = true; $('#instruct_enabled').prop('checked', true).trigger('change'); - toastr.info('Instruct Mode enabled'); + !quiet && toastr.info('Instruct Mode enabled'); } saveSettingsDebounced(); diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index fcc6efb87..ecc2b2259 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -1477,6 +1477,15 @@ export function initDefaultSlashCommands() { name: 'model', callback: modelCallback, returns: 'current model', + namedArgumentList: [ + SlashCommandNamedArgument.fromProps({ + name: 'quiet', + description: 'suppress the toast message on model change', + typeList: [ARGUMENT_TYPE.BOOLEAN], + defaultValue: 'false', + enumList: commonEnumProviders.boolean('trueFalse')(), + }), + ], unnamedArgumentList: [ SlashCommandArgument.fromProps({ description: 'model name', @@ -3382,11 +3391,11 @@ function getModelOptions() { /** * Sets a model for the current API. - * @param {object} _ Unused + * @param {object} args Named arguments * @param {string} model New model name * @returns {string} New or existing model name */ -function modelCallback(_, model) { +function modelCallback(args, model) { const { control: modelSelectControl, options } = getModelOptions(); // If no model was found, the reason was already logged, we just return here @@ -3426,7 +3435,8 @@ function modelCallback(_, model) { if (newSelectedOption) { modelSelectControl.value = newSelectedOption.value; $(modelSelectControl).trigger('change'); - toastr.success(`Model set to "${newSelectedOption.text}"`); + const quiet = isTrueBoolean(args?.quiet); + !quiet && toastr.success(`Model set to "${newSelectedOption.text}"`); return newSelectedOption.value; } else { toastr.warning(`No model found with name "${model}"`);