diff --git a/public/index.html b/public/index.html index c276f29e4..d1a6db538 100644 --- a/public/index.html +++ b/public/index.html @@ -1622,6 +1622,10 @@

+ Banned Tokens/Strings

diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 392e33546..027fca9fb 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'; @@ -183,6 +184,7 @@ const settings = { 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, @@ -276,6 +278,7 @@ export const setting_names = [ 'json_schema', 'banned_tokens', 'global_banned_tokens', + 'send_banned_tokens', 'ignore_eos_token', 'spaces_between_special_tokens', 'speculative_ngram', @@ -455,6 +458,22 @@ function getCustomTokenBans() { }; } +async function enableBannedStringsKillSwitch() { + $('#send_banned_tokens_textgenerationwebui').prop('checked', true); + $('#send_banned_tokens_label').find('.menu_button').addClass('toggleEnabled').prop('title', t`Banned tokens/strings are being sent into the request.`); + settings.send_banned_tokens = true; + saveSettingsDebounced(); + return ''; +} + +async function disableBannedStringsKillSwitch() { + $('#send_banned_tokens_textgenerationwebui').prop('checked', false); + $('#send_banned_tokens_label').find('.menu_button').removeClass('toggleEnabled').prop('title', t`Banned tokens/strings are NOT being sent into the request.`); + settings.send_banned_tokens = false; + saveSettingsDebounced(); + return ''; +} + /** * Calculates logit bias object from the logit bias list. * @returns {object} Logit bias object @@ -597,6 +616,16 @@ function sortAphroditeItemsByOrder(orderArray) { } jQuery(function () { + + $('#bannedStringsKillSwitch_textgenerationwebui').on('change', function () { + const checked = $(this).prop('checked'); + if (checked) { + enableBannedStringsKillSwitch(); + } else { + disableBannedStringsKillSwitch(); + } + }); + $('#koboldcpp_order').sortable({ delay: getSortableDelay(), stop: function () { @@ -935,6 +964,10 @@ function setSettingByName(setting, value, trigger) { if (isCheckbox) { const val = Boolean(value); $(`#${setting}_textgenerationwebui`).prop('checked', val); + + if ('send_banned_tokens' === setting) { + $('#send_banned_tokens_textgenerationwebui').trigger('change'); + } } else if (isText) { $(`#${setting}_textgenerationwebui`).val(value); diff --git a/public/style.css b/public/style.css index b56a87cd0..1aac652f2 100644 --- a/public/style.css +++ b/public/style.css @@ -2875,7 +2875,8 @@ select option:not(:checked) { } #instruct_enabled_label .menu_button:not(.toggleEnabled), -#sysprompt_enabled_label .menu_button:not(.toggleEnabled) { +#sysprompt_enabled_label .menu_button:not(.toggleEnabled), +#bannedStringsKillSwitch_label .menu_button:not(.toggleEnabled) { color: Red; }