mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'Banned-Strings-Killswitch' into tc-global-banlist
This commit is contained in:
@ -1622,6 +1622,10 @@
|
||||
<div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
|
||||
<hr class="width100p">
|
||||
<h4 class="range-block-title justifyCenter">
|
||||
<label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
|
||||
<input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
|
||||
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
|
||||
</label>
|
||||
<span data-i18n="Banned Tokens">Banned Tokens/Strings</span>
|
||||
<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>
|
||||
</h4>
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user