diff --git a/public/css/toggle-dependent.css b/public/css/toggle-dependent.css index 967aa55e6..59c2e9a28 100644 --- a/public/css/toggle-dependent.css +++ b/public/css/toggle-dependent.css @@ -493,3 +493,7 @@ label[for="trim_spaces"]:not(:has(input:checked)) small { #mistralai_other_models:empty { display: none; } + +#banned_tokens_block_ooba:not(:has(#send_banned_tokens_textgenerationwebui:checked)) #banned_tokens_controls_ooba { + filter: brightness(0.5); +} diff --git a/public/index.html b/public/index.html index d46dab4fd..b6a3e6557 100644 --- a/public/index.html +++ b/public/index.html @@ -1621,17 +1621,34 @@

-

- Banned Tokens/Strings -
-

-
- +
+
+ Banned Tokens/Strings +
+
+ +
+
+
+ Global list +
+
+ +
+
+ Preset-specific list +
+
+ +
- Logit Bias + Logit Bias
Add @@ -3517,7 +3534,7 @@
@@ -3695,7 +3712,7 @@
diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 0d7d3c133..14991900f 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -587,6 +587,8 @@ class PresetManager { 'derived', 'generic_model', 'include_reasoning', + 'global_banned_tokens', + 'send_banned_tokens', ]; const settings = Object.assign({}, getSettingsByApiId(this.apiId)); diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 50c630841..7fefed1d9 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -10,6 +10,7 @@ import { setOnlineStatus, substituteParams, } from '../script.js'; +import { t } from './i18n.js'; import { BIAS_CACHE, createNewLogitBiasEntry, displayLogitBias, getLogitBiasListResult } from './logit-bias.js'; import { power_user, registerDebugFunction } from './power-user.js'; @@ -182,6 +183,8 @@ const settings = { grammar_string: '', json_schema: {}, banned_tokens: '', + global_banned_tokens: '', + send_banned_tokens: true, sampler_priority: OOBA_DEFAULT_ORDER, samplers: LLAMACPP_DEFAULT_ORDER, samplers_priorities: APHRODITE_DEFAULT_ORDER, @@ -274,6 +277,8 @@ export const setting_names = [ 'grammar_string', 'json_schema', 'banned_tokens', + 'global_banned_tokens', + 'send_banned_tokens', 'ignore_eos_token', 'spaces_between_special_tokens', 'speculative_ngram', @@ -394,7 +399,7 @@ function getTokenizerForTokenIds() { * @returns {TokenBanResult} String with comma-separated banned token IDs */ function getCustomTokenBans() { - if (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length) { + if (!settings.send_banned_tokens || (!settings.banned_tokens && !settings.global_banned_tokens && !textgenerationwebui_banned_in_macros.length)) { return { banned_tokens: '', banned_strings: [], @@ -404,8 +409,9 @@ function getCustomTokenBans() { const tokenizer = getTokenizerForTokenIds(); const banned_tokens = []; const banned_strings = []; - const sequences = settings.banned_tokens - .split('\n') + const sequences = [] + .concat(settings.banned_tokens.split('\n')) + .concat(settings.global_banned_tokens.split('\n')) .concat(textgenerationwebui_banned_in_macros) .filter(x => x.length > 0) .filter(onlyUnique); @@ -452,6 +458,18 @@ function getCustomTokenBans() { }; } +/** + * Sets the banned strings kill switch toggle. + * @param {boolean} isEnabled Kill switch state + * @param {string} title Label title + */ +function toggleBannedStringsKillSwitch(isEnabled, title) { + $('#send_banned_tokens_textgenerationwebui').prop('checked', isEnabled); + $('#send_banned_tokens_label').find('.menu_button').toggleClass('toggleEnabled', isEnabled).prop('title', title); + settings.send_banned_tokens = isEnabled; + saveSettingsDebounced(); +} + /** * Calculates logit bias object from the logit bias list. * @returns {object} Logit bias object @@ -594,6 +612,14 @@ function sortAphroditeItemsByOrder(orderArray) { } jQuery(function () { + $('#send_banned_tokens_textgenerationwebui').on('change', function () { + const checked = !!$(this).prop('checked'); + toggleBannedStringsKillSwitch(checked, + checked + ? t`Banned tokens/strings are being sent in the request.` + : t`Banned tokens/strings are NOT being sent in the request.`); + }); + $('#koboldcpp_order').sortable({ delay: getSortableDelay(), stop: function () { @@ -932,6 +958,10 @@ function setSettingByName(setting, value, trigger) { if (isCheckbox) { const val = Boolean(value); $(`#${setting}_textgenerationwebui`).prop('checked', val); + + if ('send_banned_tokens' === setting) { + $(`#${setting}_textgenerationwebui`).trigger('change'); + } } else if (isText) { $(`#${setting}_textgenerationwebui`).val(value); diff --git a/public/style.css b/public/style.css index d045ab5c5..ff585ca65 100644 --- a/public/style.css +++ b/public/style.css @@ -2879,9 +2879,8 @@ select option:not(:checked) { color: var(--active) !important; } -#instruct_enabled_label .menu_button:not(.toggleEnabled), -#sysprompt_enabled_label .menu_button:not(.toggleEnabled) { - color: Red; +.menu_button.togglable:not(.toggleEnabled) { + color: red; } .displayBlock {