Add quiet args to /instruct and /model

c68b344b6052b9bb2e0d6bbce10416ba8c4c1e6d

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +29 -8Showing whitespace changes
public/script.js+12 -2
@@ -8522,7 +8522,7 @@ async function selectContextCallback(_, name) {
85228522 return foundName;
85238523}
85248524
85258525async function selectInstructCallback(_args, name) {
85268526 if (!name) {
85278527 return power_user.instruct.preset;
85288528 }
@@ -8536,8 +8536,9 @@ async function selectInstructCallback(_, name) {
85368536 return '';
85378537 }
85388538
8539+ const quiet = isTrueBoolean(args?.quiet);
85398540 const foundName = result[0].item;
85408541 selectInstructPreset(foundName, quiet);
85418542 return foundName;
85428543}
85438544
@@ -9216,6 +9217,15 @@ jQuery(async function () {
92169217 name: 'instruct',
92179218 callback: selectInstructCallback,
92189219 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+ ],
92199229 unnamedArgumentList: [
92209230 SlashCommandArgument.fromProps({
92219231 description: 'instruct template name',
public/scripts/instruct-mode.js+4 -3
@@ -151,19 +151,20 @@ export function selectContextPreset(preset) {
151151/**
152152 * Select instruct preset if not already selected.
153153 * @param {string} preset Preset name.
154+ * @param {boolean} quiet Suppress info message.
154155 */
155156export function selectInstructPreset(preset, quiet) {
156157 // If instruct preset is not already selected, select it
157158 if (preset !== power_user.instruct.preset) {
158159 $('#instruct_presets').val(preset).trigger('change');
159160 !quiet && toastr.info(`Instruct Mode: template "${preset}" auto-selected`);
160161 }
161162
162163 // If instruct mode is disabled, enable it
163164 if (!power_user.instruct.enabled) {
164165 power_user.instruct.enabled = true;
165166 $('#instruct_enabled').prop('checked', true).trigger('change');
166167 !quiet && toastr.info('Instruct Mode enabled');
167168 }
168169
169170 saveSettingsDebounced();
public/scripts/slash-commands.js+13 -3
@@ -1477,6 +1477,15 @@ export function initDefaultSlashCommands() {
14771477 name: 'model',
14781478 callback: modelCallback,
14791479 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+ ],
14801489 unnamedArgumentList: [
14811490 SlashCommandArgument.fromProps({
14821491 description: 'model name',
@@ -3382,11 +3391,11 @@ function getModelOptions() {
33823391
33833392/**
33843393 * Sets a model for the current API.
33853394 * @param {object} _args UnusedNamed arguments
33863395 * @param {string} model New model name
33873396 * @returns {string} New or existing model name
33883397 */
33893398function modelCallback(_args, model) {
33903399 const { control: modelSelectControl, options } = getModelOptions();
33913400
33923401 // If no model was found, the reason was already logged, we just return here
@@ -3426,7 +3435,8 @@ function modelCallback(_, model) {
34263435 if (newSelectedOption) {
34273436 modelSelectControl.value = newSelectedOption.value;
34283437 $(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}"`);
34303440 return newSelectedOption.value;
34313441 } else {
34323442 toastr.warning(`No model found with name "${model}"`);