From 830df4138092e5027a0f81e2af0b68a76b3973e7 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:59:41 +0300 Subject: [PATCH 1/2] Update Advanced Formatting verbiage --- public/index.html | 32 ++++++++++---------- public/script.js | 16 +++++----- public/scripts/instruct-mode.js | 6 ++-- public/scripts/preset-manager.js | 51 ++++++++++++++++++++++---------- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/public/index.html b/public/index.html index c2c93fb2a..b8d24884e 100644 --- a/public/index.html +++ b/public/index.html @@ -3073,13 +3073,13 @@
- - - - - - - + + + + + + +
@@ -3196,7 +3196,7 @@

- Instruct Mode + Instruct Template @@ -3214,13 +3214,13 @@

- - - - - - - + + + + + + +
@@ -3229,7 +3229,7 @@
diff --git a/public/script.js b/public/script.js index f35fa532c..3dd51692f 100644 --- a/public/script.js +++ b/public/script.js @@ -8511,7 +8511,7 @@ async function selectContextCallback(_, name) { const result = fuse.search(name); if (result.length === 0) { - toastr.warning(`Context preset "${name}" not found`); + toastr.warning(`Context template "${name}" not found`); return ''; } @@ -8530,7 +8530,7 @@ async function selectInstructCallback(_, name) { const result = fuse.search(name); if (result.length === 0) { - toastr.warning(`Instruct preset "${name}" not found`); + toastr.warning(`Instruct template "${name}" not found`); return ''; } @@ -9054,8 +9054,8 @@ API: ${getSettingsContents.main_api} API Type: ${getSettingsContents[getSettingsContents.main_api + '_settings'].type} API server: ${getSettingsContents.api_server} Model: ${getContextContents.onlineStatus} -Context Preset: ${power_user.context.preset} -Instruct Preset: ${power_user.instruct.preset} +Context Template: ${power_user.context.preset} +Instruct Template: ${power_user.instruct.preset} API Settings: ${JSON.stringify(getSettingsContents[getSettingsContents.main_api + '_settings'], null, 2)} \`\`\` `; @@ -9193,17 +9193,17 @@ jQuery(async function () { SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'instruct', callback: selectInstructCallback, - returns: 'current preset', + returns: 'current template', unnamedArgumentList: [ SlashCommandArgument.fromProps({ - description: 'instruct preset name', + description: 'instruct template name', typeList: [ARGUMENT_TYPE.STRING], enumProvider: () => instruct_presets.map(preset => new SlashCommandEnumValue(preset.name, null, enumTypes.enum, enumIcons.preset)), }), ], helpString: `
- Selects instruct mode preset by name. Gets the current instruct if no name is provided. + Selects instruct mode template by name. Gets the current instruct template if no name is provided.
Example: @@ -9231,7 +9231,7 @@ jQuery(async function () { returns: 'template name', unnamedArgumentList: [ SlashCommandArgument.fromProps({ - description: 'context preset name', + description: 'context template name', typeList: [ARGUMENT_TYPE.STRING], enumProvider: () => context_presets.map(preset => new SlashCommandEnumValue(preset.name, null, enumTypes.enum, enumIcons.preset)), }), diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 366a8da6d..c62a1bf34 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -156,7 +156,7 @@ export function selectInstructPreset(preset) { // 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: preset "${preset}" auto-selected`); + toastr.info(`Instruct Mode: template "${preset}" auto-selected`); } // If instruct mode is disabled, enable it @@ -596,11 +596,11 @@ jQuery(() => { if (power_user.instruct.preset === power_user.default_instruct) { power_user.default_instruct = null; $(this).removeClass('default'); - toastr.info('Default instruct preset cleared'); + toastr.info('Default instruct template cleared'); } else { power_user.default_instruct = power_user.instruct.preset; $(this).addClass('default'); - toastr.info(`Default instruct preset set to ${power_user.default_instruct}`); + toastr.info(`Default instruct template set to ${power_user.default_instruct}`); } saveSettingsDebounced(); diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 88d7f3bf2..896de485e 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -160,20 +160,25 @@ class PresetManager { const name = selected.text(); await this.savePreset(name); - toastr.success('Preset updated'); + + const successToast = !this.isAdvancedFormatting() ? 'Preset updated' : 'Template updated'; + toastr.success(successToast); } async savePresetAs() { const inputValue = this.getSelectedPresetName(); - const popupText = !this.isNonGenericApi() ? '

Hint: Use a character/group name to bind preset to a specific chat.

' : ''; - const name = await Popup.show.input('Preset name:', popupText, inputValue); + const popupText = !this.isAdvancedFormatting() ? '

Hint: Use a character/group name to bind preset to a specific chat.

' : ''; + const headerText = !this.isAdvancedFormatting() ? 'Preset name:' : 'Template name:'; + const name = await Popup.show.input(headerText, popupText, inputValue); if (!name) { console.log('Preset name not provided'); return; } await this.savePreset(name); - toastr.success('Preset saved'); + + const successToast = !this.isAdvancedFormatting() ? 'Preset saved' : 'Template saved'; + toastr.success(successToast); } async savePreset(name, settings) { @@ -234,7 +239,7 @@ class PresetManager { return this.apiId == 'textgenerationwebui' || this.apiId == 'context' || this.apiId == 'instruct'; } - isNonGenericApi() { + isAdvancedFormatting() { return this.apiId == 'context' || this.apiId == 'instruct'; } @@ -342,7 +347,7 @@ class PresetManager { } } - if (!this.isNonGenericApi()) { + if (!this.isAdvancedFormatting()) { settings['genamt'] = amount_gen; settings['max_length'] = max_context; } @@ -394,7 +399,8 @@ class PresetManager { }); if (!response.ok) { - toastr.error('Failed to restore default preset'); + const errorToast = !this.isAdvancedFormatting() ? 'Failed to restore default preset' : 'Failed to restore default template'; + toastr.error(errorToast); return; } @@ -580,7 +586,8 @@ export async function initPresetManager() { data['name'] = name; await presetManager.savePreset(name, data); - toastr.success('Preset imported'); + const successToast = !presetManager.isAdvancedFormatting() ? 'Preset imported' : 'Template imported'; + toastr.success(successToast); e.target.value = null; }); @@ -598,7 +605,8 @@ export async function initPresetManager() { return; } - const confirm = await Popup.show.confirm('Delete the preset?', 'This action is irreversible and your current settings will be overwritten.'); + const headerText = !presetManager.isAdvancedFormatting() ? 'Delete this preset?' : 'Delete this template?'; + const confirm = await Popup.show.confirm(headerText, 'This action is irreversible and your current settings will be overwritten.'); if (!confirm) { return; } @@ -606,9 +614,11 @@ export async function initPresetManager() { const result = await presetManager.deleteCurrentPreset(); if (result) { - toastr.success('Preset deleted'); + const successToast = !presetManager.isAdvancedFormatting() ? 'Preset deleted' : 'Template deleted'; + toastr.success(successToast); } else { - toastr.warning('Preset was not deleted from server'); + const warningToast = !presetManager.isAdvancedFormatting() ? 'Preset was not deleted from server' : 'Template was not deleted from server'; + toastr.warning(warningToast); } saveSettingsDebounced(); @@ -637,11 +647,15 @@ export async function initPresetManager() { if (data.isDefault) { if (Object.keys(data.preset).length === 0) { - toastr.error('Default preset cannot be restored'); + const errorToast = !presetManager.isAdvancedFormatting() ? 'Default preset cannot be restored' : 'Default template cannot be restored'; + toastr.error(errorToast); return; } - const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a default preset will restore the default settings.'); + const confirmText = !presetManager.isAdvancedFormatting() + ? 'Resetting a default preset will restore the default settings.' + : 'Resetting a default template will restore the default settings.'; + const confirm = await Popup.show.confirm('Are you sure?', confirmText); if (!confirm) { return; } @@ -650,16 +664,21 @@ export async function initPresetManager() { await presetManager.savePreset(name, data.preset); const option = presetManager.findPreset(name); presetManager.selectPreset(option); - toastr.success('Default preset restored'); + const successToast = !presetManager.isAdvancedFormatting() ? 'Default preset restored' : 'Default template restored'; + toastr.success(successToast); } else { - const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a custom preset will restore to the last saved state.'); + const confirmText = !presetManager.isAdvancedFormatting() + ? 'Resetting a custom preset will restore to the last saved state.' + : 'Resetting a custom template will restore to the last saved state.'; + const confirm = await Popup.show.confirm('Are you sure?', confirmText); if (!confirm) { return; } const option = presetManager.findPreset(name); presetManager.selectPreset(option); - toastr.success('Preset restored'); + const successToast = !presetManager.isAdvancedFormatting() ? 'Preset restored' : 'Template restored'; + toastr.success(successToast); } }); } From 8550fd5fe6c6c75197d8cea4aafce0059594eb08 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 3 Sep 2024 23:21:24 +0300 Subject: [PATCH 2/2] Add tooltips to dropdowns --- public/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index b8d24884e..a22250c3f 100644 --- a/public/index.html +++ b/public/index.html @@ -3081,7 +3081,7 @@
-
+
@@ -3223,7 +3223,7 @@
-
+