Merge branch 'Banned-Strings-Killswitch' into tc-global-banlist
| @@ -1622,6 +1622,10 @@ | ||
| 1622 | 1622 | <div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p"> |
| 1623 | 1623 | <hr class="width100p"> |
| 1624 | 1624 | <h4 class="range-block-title justifyCenter"> |
| 1625 | + <label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label"> | |
| 1626 | + <input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" /> | |
| 1627 | + <small><i class="fa-solid fa-power-off menu_button margin0"></i></small> | |
| 1628 | + </label> | |
| 1625 | 1629 | <span data-i18n="Banned Tokens">Banned Tokens/Strings</span> |
| 1626 | 1630 | <div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output. Unquoted text will be tokenized in the back end and banned as tokens. [token ids] will be banned as-is. Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure. Enclose text in double quotes to ban the entire string as a set. Quoted Strings and [Token ids] must be on their own line."></div> |
| 1627 | 1631 | </h4> |
| @@ -10,6 +10,7 @@ import { | ||
| 10 | 10 | setOnlineStatus, |
| 11 | 11 | substituteParams, |
| 12 | 12 | } from '../script.js'; |
| 13 | +import { t } from './i18n.js'; | |
| 13 | 14 | import { BIAS_CACHE, createNewLogitBiasEntry, displayLogitBias, getLogitBiasListResult } from './logit-bias.js'; |
| 14 | 15 | |
| 15 | 16 | import { power_user, registerDebugFunction } from './power-user.js'; |
| @@ -183,6 +184,7 @@ const settings = { | ||
| 183 | 184 | json_schema: {}, |
| 184 | 185 | banned_tokens: '', |
| 185 | 186 | global_banned_tokens: '', |
| 187 | + send_banned_tokens: true, | |
| 186 | 188 | sampler_priority: OOBA_DEFAULT_ORDER, |
| 187 | 189 | samplers: LLAMACPP_DEFAULT_ORDER, |
| 188 | 190 | samplers_priorities: APHRODITE_DEFAULT_ORDER, |
| @@ -276,6 +278,7 @@ export const setting_names = [ | ||
| 276 | 278 | 'json_schema', |
| 277 | 279 | 'banned_tokens', |
| 278 | 280 | 'global_banned_tokens', |
| 281 | + 'send_banned_tokens', | |
| 279 | 282 | 'ignore_eos_token', |
| 280 | 283 | 'spaces_between_special_tokens', |
| 281 | 284 | 'speculative_ngram', |
| @@ -455,6 +458,22 @@ function getCustomTokenBans() { | ||
| 455 | 458 | }; |
| 456 | 459 | } |
| 457 | 460 | |
| 461 | +async function enableBannedStringsKillSwitch() { | |
| 462 | + $('#send_banned_tokens_textgenerationwebui').prop('checked', true); | |
| 463 | + $('#send_banned_tokens_label').find('.menu_button').addClass('toggleEnabled').prop('title', t`Banned tokens/strings are being sent into the request.`); | |
| 464 | + settings.send_banned_tokens = true; | |
| 465 | + saveSettingsDebounced(); | |
| 466 | + return ''; | |
| 467 | +} | |
| 468 | + | |
| 469 | +async function disableBannedStringsKillSwitch() { | |
| 470 | + $('#send_banned_tokens_textgenerationwebui').prop('checked', false); | |
| 471 | + $('#send_banned_tokens_label').find('.menu_button').removeClass('toggleEnabled').prop('title', t`Banned tokens/strings are NOT being sent into the request.`); | |
| 472 | + settings.send_banned_tokens = false; | |
| 473 | + saveSettingsDebounced(); | |
| 474 | + return ''; | |
| 475 | +} | |
| 476 | + | |
| 458 | 477 | /** |
| 459 | 478 | * Calculates logit bias object from the logit bias list. |
| 460 | 479 | * @returns {object} Logit bias object |
| @@ -597,6 +616,16 @@ function sortAphroditeItemsByOrder(orderArray) { | ||
| 597 | 616 | } |
| 598 | 617 | |
| 599 | 618 | jQuery(function () { |
| 619 | + | |
| 620 | + $('#bannedStringsKillSwitch_textgenerationwebui').on('change', function () { | |
| 621 | + const checked = $(this).prop('checked'); | |
| 622 | + if (checked) { | |
| 623 | + enableBannedStringsKillSwitch(); | |
| 624 | + } else { | |
| 625 | + disableBannedStringsKillSwitch(); | |
| 626 | + } | |
| 627 | + }); | |
| 628 | + | |
| 600 | 629 | $('#koboldcpp_order').sortable({ |
| 601 | 630 | delay: getSortableDelay(), |
| 602 | 631 | stop: function () { |
| @@ -935,6 +964,10 @@ function setSettingByName(setting, value, trigger) { | ||
| 935 | 964 | if (isCheckbox) { |
| 936 | 965 | const val = Boolean(value); |
| 937 | 966 | $(`#${setting}_textgenerationwebui`).prop('checked', val); |
| 967 | + | |
| 968 | + if ('send_banned_tokens' === setting) { | |
| 969 | + $('#send_banned_tokens_textgenerationwebui').trigger('change'); | |
| 970 | + } | |
| 938 | 971 | } |
| 939 | 972 | else if (isText) { |
| 940 | 973 | $(`#${setting}_textgenerationwebui`).val(value); |
| @@ -2875,7 +2875,8 @@ select option:not(:checked) { | ||
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | #instruct_enabled_label .menu_button:not(.toggleEnabled), |
| 2878 | 2878 | #sysprompt_enabled_label .menu_button:not(.toggleEnabled) {, |
| 2879 | +#bannedStringsKillSwitch_label .menu_button:not(.toggleEnabled) { | |
| 2879 | 2880 | color: Red; |
| 2880 | 2881 | } |
| 2881 | 2882 | |