Add option to keep manually selected samplers on API Type switch (#4692) * Feat - Save and load manually selected samplers per preset * Fix - Sync sampler popup with selected sampler state settings * Fix - Prevent breaking visualization after disabling keep selected samplers * Fix - ESLint errors in samplerSelect.js * Fix - ESLint errors in textgen-settings.js * Docs - Write JSDocs for new methods in textgen-settings.js * Update - Make the reset button work individually per preset * Fix - Trailing whitespace at the end of class selector * Fix - Update tooltip information for force samplers toggle * Fix - Prevent calling isSamplerManualPriorityEnabled a bajillion times * Fix - Unbrick switch from manually-forced to non-manually-forced preset This prevents samplers non controlled by [data-tg-type] from being sent to the shadow realm if they were previously hidden by [data-tg-samplers]. is_preset_switch is just to prevent breaking muscle memmory of users not using force manually selected samplers. * Fix - Load manually selected samplers on connection profile switch Changing preset does not update samplers ONLY IF force manually selection is disabled. Changing API before preset would update the samplers, but using the settings of the previous preset, due to preset being changed AFTER the API. * Fix - Switch API Type controls in the API Connections panel * Fix - ESLint errors in textgen-settings.js * Fix - Update sampler selection only with textgenerationwebui as main API selected * Styles - Change the sampler selection lock button icon to an actual lock. * Fix - Await for sampler selection reset to finish * Update - Normalize function name * Update - Preserve manual sampler selections on preset renaming * Fix - Properly reset sampler manual selections * Update - Ensure selection reset displays API specific samplers * Fix - ESLint errors * Fix - Avoid modifying non-existent data * Update - Move manual sampler control methods to samplerSelect.js * Fix - Break circular file dependency between textgen-settings.js and samplerSelect.js setting_names was unavailable during page load, throwing an error and preventing ST from loading. * Update menu layout * Remove pointless await * Update param naming to camelCase --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

0d9a72becc83556c75dbd536b030ca0c8e46fc79

Leandro Jofré <leandrotomasjofre@gmail.com>

Signed
6 files changed, +301 -80Showing whitespace changes
public/index.html+65 -65
@@ -1246,12 +1246,12 @@
12461246 <div class="fa-solid fa-circle-info opacity50p" title="Customize displayed samplers or add custom samplers." data-i18n="[title]Customize displayed samplers or add custom samplers."></div>
12471247 </small>
12481248 </div>
12491249 <div data-tg-type="mancer, vllm, aphrodite, tabby, infermaticai" data-tg-samplers="n" class="flex-container flexFlowColumn alignitemscenter flexBasis100p flexGrow flexShrink gap0">
12501250 <small data-i18n="Multiple swipes per generation">Multiple swipes per generation</small>
12511251 <input type="number" id="n_textgenerationwebui" class="text_pole textAlignCenter" min="1" value="1" step="1" />
12521252 </div>
12531253 <div class="flex-container gap10h5v justifyCenter">
12541254 <div data-tg-samplers="temp" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12551255 <small>
12561256 <span data-i18n="Temperature">Temperature</span>
12571257 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Temperature controls the randomness in token selection" title="Temperature controls the randomness in token selection:&#13;- low temperature (<1.0) leads to more predictable text, favoring higher probability tokens.&#13;- high temperature (>1.0) increases creativity and diversity in the output by giving lower probability tokens a better chance.&#13;Set to 1.0 for the original probabilities."></div>
@@ -1260,7 +1260,7 @@
12601260 <input class="neo-range-input" type="number" min="0.0" max="5.0" step="0.01" data-for="temp_textgenerationwebui" id="temp_counter_textgenerationwebui">
12611261 </div>
12621262 <!-- Note: "except" mode = show for all BUT types in data-tg-type -->
12631263 <div data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="top_k" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12641264 <small>
12651265 <span data-i18n="Top K">Top K</span>
12661266 <div class="fa-solid fa-circle-info opacity50p" title="Top K sets a maximum amount of top tokens that can be chosen from.&#13;E.g Top K is 20, this means only the 20 highest ranking tokens will be kept (regardless of their probabilities being diverse or limited).&#13;Set to 0 (or -1, depending on your backend) to disable." data-i18n="[title]Top_K_desc"></div>
@@ -1268,7 +1268,7 @@
12681268 <input class="neo-range-slider" type="range" id="top_k_textgenerationwebui" name="volume" min="-1" max="200" step="1">
12691269 <input class="neo-range-input" type="number" min="-1" max="200" step="1" data-for="top_k_textgenerationwebui" id="top_k_counter_textgenerationwebui">
12701270 </div>
12711271 <div data-tg-samplers="top_p" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12721272 <small>
12731273 <span data-i18n="Top P">Top P</span>
12741274 <div class="fa-solid fa-circle-info opacity50p" title="Top P (a.k.a. nucleus sampling) adds up all the top tokens required to add up to the target percentage.&#13;E.g If the Top 2 tokens are both 25%, and Top P is 0.50, only the Top 2 tokens are considered.&#13;Set to 1.0 to disable." data-i18n="[title]Top_P_desc"></div>
@@ -1276,7 +1276,7 @@
12761276 <input class="neo-range-slider" type="range" id="top_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
12771277 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_p_textgenerationwebui" id="top_p_counter_textgenerationwebui">
12781278 </div>
12791279 <div data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="typical_p" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12801280 <small>
12811281 <span data-i18n="Typical P">Typical P</span>
12821282 <div class="fa-solid fa-circle-info opacity50p" title="Typical P Sampling prioritizes tokens based on their deviation from the average entropy of the set.&#13;It maintains tokens whose cumulative probability is close to a predefined threshold (e.g., 0.5), emphasizing those with average information content.&#13;Set to 1.0 to disable." data-i18n="[title]Typical_P_desc"></div>
@@ -1284,7 +1284,7 @@
12841284 <input class="neo-range-slider" type="range" id="typical_p_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
12851285 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="typical_p_textgenerationwebui" id="typical_p_counter_textgenerationwebui">
12861286 </div>
12871287 <div data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="min_p" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12881288 <small>
12891289 <span data-i18n="Min P">Min P</span>
12901290 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Min_P_desc" title="Min P sets a base minimum probability. This is scaled according to the top token's probability.&#13;E.g If Top token is 80% probability, and Min P is 0.1, only tokens higher than 8% would be considered.&#13;Set to 0 to disable."></div>
@@ -1292,7 +1292,7 @@
12921292 <input class="neo-range-slider" type="range" id="min_p_textgenerationwebui" name="volume" min="0" max="1" step="0.001">
12931293 <input class="neo-range-input" type="number" min="0" max="1" step="0.001" data-for="min_p_textgenerationwebui" id="min_p_counter_textgenerationwebui">
12941294 </div>
12951295 <div data-tg-type-mode="except" data-tg-type="generic,llamacpp" data-tg-samplers="top_a" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
12961296 <small>
12971297 <span data-i18n="Top A">Top A</span>
12981298 <div class="fa-solid fa-circle-info opacity50p" title="Top A sets a threshold for token selection based on the square of the highest token probability.&#13;E.g if the Top-A value is 0.2 and the top token's probability is 50%, tokens with probabilities below 5% (0.2 * 0.5^2) are excluded.&#13;Set to 0 to disable." data-i18n="[title]Top_A_desc"></div>
@@ -1300,7 +1300,7 @@
13001300 <input class="neo-range-slider" type="range" id="top_a_textgenerationwebui" name="volume" min="0" max="1" step="0.01">
13011301 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="top_a_textgenerationwebui" id="top_a_counter_textgenerationwebui">
13021302 </div>
13031303 <div data-tg-type-mode="except" data-tg-type="generic,llamacpp" data-tg-samplers="tfs" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13041304 <small>
13051305 <span data-i18n="TFS">TFS</span>
13061306 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Tail_Free_Sampling_desc" title="Tail-Free Sampling (TFS) searches for a tail of low-probability tokens in the distribution,&#13;by analyzing the rate of change in token probabilities using derivatives. It retains tokens up to a threshold (e.g., 0.3) based on the normalized second derivative.&#13;The closer to 0, the more discarded tokens. Set to 1.0 to disable."></div>
@@ -1308,7 +1308,7 @@
13081308 <input class="neo-range-slider" type="range" id="tfs_textgenerationwebui" name="volume" min="0" max="1" step="0.001">
13091309 <input class="neo-range-input" type="number" min="0" max="1" step="0.001" data-for="tfs_textgenerationwebui" id="tfs_counter_textgenerationwebui">
13101310 </div>
13111311 <div data-tg-type="ooba,mancer,aphrodite" data-tg-samplers="epsilon_cutoff" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13121312 <small>
13131313 <span data-i18n="Epsilon Cutoff">Epsilon Cutoff</span>
13141314 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Epsilon cutoff sets a probability floor below which tokens are excluded from being sampled" title="Epsilon cutoff sets a probability floor below which tokens are excluded from being sampled.&#13;In units of 1e-4; a reasonable value is 3.&#13;Set to 0 to disable."></div>
@@ -1316,7 +1316,7 @@
13161316 <input class="neo-range-slider" type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">
13171317 <input class="neo-range-input" type="number" min="0" max="9" step="0.01" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">
13181318 </div>
13191319 <div data-tg-type="ooba,aphrodite,koboldcpp,llamacpp" data-tg-samplers="nsigma" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13201320 <small>
13211321 <span data-i18n="Top nsigma">Top nsigma</span>
13221322 <div class="fa-solid fa-circle-info opacity50p" title="A sampling method that filters logits based on their statistical properties. It keeps tokens within n standard deviations of the maximum logit value, providing a simpler alternative to top-p/top-k sampling while maintaining sampling stability across different temperatures."></div>
@@ -1324,7 +1324,7 @@
13241324 <input class="neo-range-slider" type="range" id="nsigma_textgenerationwebui" name="volume" min="0" max="5" step="0.01">
13251325 <input class="neo-range-input" type="number" min="0" max="5" step="0.01" data-for="nsigma_textgenerationwebui" id="nsigma_counter_textgenerationwebui">
13261326 </div>
13271327 <div data-tg-type="llamacpp" data-tg-samplers="min_keep" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13281328 <small>
13291329 <span data-i18n="Min Keep">Min Keep</span>
13301330 <div class="fa-solid fa-circle-info opacity50p" title="A sampling modifier that ensures that truncation samplers such as top-p, min-p, typical-p, and xtc return at least this many tokens. Set to 0 to disable."></div>
@@ -1332,7 +1332,7 @@
13321332 <input class="neo-range-slider" type="range" id="min_keep_textgenerationwebui" name="volume" min="0" max="50" step="1">
13331333 <input class="neo-range-input" type="number" min="0" max="50" step="1" data-for="min_keep_textgenerationwebui" id="min_keep_counter_textgenerationwebui">
13341334 </div>
13351335 <div data-tg-type="ooba,mancer,aphrodite" data-tg-samplers="eta_cutoff" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13361336 <small>
13371337 <span data-i18n="Eta Cutoff">Eta Cutoff</span>
13381338 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Eta_Cutoff_desc" title="Eta cutoff is the main parameter of the special Eta Sampling technique.&#13;In units of 1e-4; a reasonable value is 3.&#13;Set to 0 to disable.&#13;See the paper Truncation Sampling as Language Model Desmoothing by Hewitt et al. (2022) for details."></div>
@@ -1340,62 +1340,62 @@
13401340 <input class="neo-range-slider" type="range" id="eta_cutoff_textgenerationwebui" name="volume" min="0" max="20" step="0.01">
13411341 <input class="neo-range-input" type="number" min="0" max="20" step="0.01" data-for="eta_cutoff_textgenerationwebui" id="eta_cutoff_counter_textgenerationwebui">
13421342 </div>
13431343 <div data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="rep_pen" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13441344 <small data-i18n="rep.pen">Repetition Penalty</small>
13451345 <input class="neo-range-slider" type="range" id="rep_pen_textgenerationwebui" name="volume" min="1" max="3" step="0.01">
13461346 <input class="neo-range-input" type="number" min="1" max="3" step="0.01" data-for="rep_pen_textgenerationwebui" id="rep_pen_counter_textgenerationwebui">
13471347 </div>
13481348 <div data-tg-type="ooba, koboldcpp, tabby, ollama, llamacpp" data-tg-samplers="rep_pen_range" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13491349 <small data-i18n="rep.pen range">Rep Pen Range</small>
13501350 <input class="neo-range-slider" type="range" id="rep_pen_range_textgenerationwebui" name="volume" min="-1" max="8192" step="1">
13511351 <input class="neo-range-input" type="number" min="-1" max="8192" step="1" data-for="rep_pen_range_textgenerationwebui" id="rep_pen_range_counter_textgenerationwebui">
13521352 </div>
13531353 <div data-tg-type="koboldcpp" data-tg-samplers="rep_pen_slope" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13541354 <small data-i18n="Rep. Pen. Slope">Rep Pen Slope</small>
13551355 <input class="neo-range-slider" type="range" id="rep_pen_slope_textgenerationwebui" name="volume" min="0" max="10" step="0.01">
13561356 <input class="neo-range-input" type="number" min="0" max="10" step="0.01" data-for="rep_pen_slope_textgenerationwebui" id="rep_pen_slope_counter_textgenerationwebui">
13571357 </div>
13581358 <div data-tg-type="tabby" data-tg-samplers="rep_pen_decay" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13591359 <small data-i18n="rep.pen decay">Rep Pen Decay</small>
13601360 <input class="neo-range-slider" type="range" id="rep_pen_decay_textgenerationwebui" name="volume" min="-1" max="8192" step="1">
13611361 <input class="neo-range-input" type="number" min="-1" max="8192" step="1" data-for="rep_pen_decay_textgenerationwebui" id="rep_pen_decay_counter_textgenerationwebui">
13621362 </div>
13631363 <div data-tg-type="ooba" data-tg-samplers="encoder_rep_pen" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13641364 <small data-i18n="Encoder Rep. Pen.">Encoder Penalty</small>
13651365 <input class="neo-range-slider" type="range" id="encoder_rep_pen_textgenerationwebui" name="volume" min="0.8" max="1.5" step="0.01" />
13661366 <input class="neo-range-input" type="number" min="0.8" max="1.5" step="0.01" data-for="encoder_rep_pen_textgenerationwebui" id="encoder_rep_pen_counter_textgenerationwebui">
13671367 </div>
13681368 <div data-tg-samplers="freq_pen" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13691369 <small data-i18n="Frequency Penalty">Frequency Penalty</small>
13701370 <input class="neo-range-slider" type="range" id="freq_pen_textgenerationwebui" name="volume" min="-2" max="2" step="0.01" />
13711371 <input class="neo-range-input" type="number" data-for="freq_pen_textgenerationwebui" min="-2" max="2" step="0.01" id="freq_pen_counter_textgenerationwebui">
13721372 </div>
13731373 <div data-tg-samplers="presence_pen" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13741374 <small data-i18n="Presence Penalty">Presence Penalty</small>
13751375 <input class="neo-range-slider" type="range" id="presence_pen_textgenerationwebui" name="volume" min="-2" max="2" step="0.01" />
13761376 <input class="neo-range-input" type="number" min="-2" max="2" step="0.01" data-for="presence_pen_textgenerationwebui" id="presence_pen_counter_textgenerationwebui">
13771377 </div>
13781378 <div data-tg-type="aphrodite, ooba" data-tg-samplers="no_repeat_ngram_size" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13791379 <small data-i18n="No Repeat Ngram Size">No Repeat Ngram Size</small>
13801380 <input class="neo-range-slider" type="range" id="no_repeat_ngram_size_textgenerationwebui" name="volume" min="0" max="20" step="1">
13811381 <input class="neo-range-input" type="number" min="0" max="20" step="1" data-for="no_repeat_ngram_size_textgenerationwebui" id="no_repeat_ngram_size_counter_textgenerationwebui">
13821382 </div>
13831383 <div data-tg-type="tabby, aphrodite" data-tg-samplers="skew" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13841384 <small data-i18n="Skew">Skew</small>
13851385 <input class="neo-range-slider" type="range" id="skew_textgenerationwebui" name="volume" min="-5" max="5" step="0.01" />
13861386 <input class="neo-range-input" type="number" min="-5" max="5" step="0.01" data-for="skew_textgenerationwebui" id="skew_counter_textgenerationwebui">
13871387 </div>
13881388 <div data-tg-type="mancer, ooba, tabby, dreamgen, infermaticai, aphrodite" data-tg-samplers="min_length" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13891389 <small data-i18n="Min Length">Min Length</small>
13901390 <input class="neo-range-slider" type="range" id="min_length_textgenerationwebui" name="volume" min="0" max="2000" step="1" />
13911391 <input class="neo-range-input" type="number" min="0" max="2000" step="1" data-for="min_length_textgenerationwebui" id="min_length_counter_textgenerationwebui">
13921392 </div>
13931393 <div data-tg-type="ooba" data-tg-samplers="max_tokens_second" class="alignitemscenter flex-container flexFlowColumn flexBasis30p flexGrow flexShrink gap0">
13941394 <small data-i18n="Max Tokens Second">Maximum tokens/second</small>
13951395 <input class="neo-range-slider" type="range" id="max_tokens_second_textgenerationwebui" name="volume" min="0" max="20" step="1" />
13961396 <input class="neo-range-input" type="number" min="0" max="20" step="1" data-for="max_tokens_second_textgenerationwebui" id="max_tokens_second_counter_textgenerationwebui">
13971397 </div>
13981398 <div data-tg-type="mancer, ooba, koboldcpp, aphrodite, tabby" data-tg-samplers="smoothing_factor" id="smoothingBlock" name="smoothingBlock" class="wide100p">
13991399 <h4 class="wide100p textAlignCenter">
14001400 <label data-i18n="Smooth Sampling">Smooth Sampling</label>
14011401 <div class=" fa-solid fa-circle-info opacity50p " data-i18n="[title]Smooth_Sampling_desc" title="Allows you to use quadratic/cubic transformations to adjust the distribution. Lower Smoothing Factor values will be more creative, usually between 0.2-0.3 is the sweetspot (assuming the curve = 1). Higher Smoothing Curve values will make the curve steeper, which will punish low probability choices more aggressively. 1.0 curve is equivalent to only using Smoothing Factor."></div>
@@ -1406,7 +1406,7 @@
14061406 <input class="neo-range-slider" type="range" id="smoothing_factor_textgenerationwebui" name="volume" min="0" max="10" step="0.01" />
14071407 <input class="neo-range-input" type="number" min="0" max="10" step="0.01" data-for="smoothing_factor_textgenerationwebui" id="smoothing_factor_counter_textgenerationwebui">
14081408 </div>
14091409 <div data-tg-type="mancer, ooba, koboldcpp, aphrodite" data-tg-samplers="smoothing_curve" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0">
14101410 <small data-i18n="Smoothing Curve">Smoothing Curve</small>
14111411 <input class="neo-range-slider" type="range" id="smoothing_curve_textgenerationwebui" name="volume" min="1" max="10" step="0.01" />
14121412 <input class="neo-range-input" type="number" min="1" max="10" step="0.01" data-for="smoothing_curve_textgenerationwebui" id="smoothing_curve_counter_textgenerationwebui">
@@ -1414,7 +1414,7 @@
14141414 </div>
14151415 </div>
14161416
14171417 <div data-tg-type="koboldcpp, aphrodite, mancer, tabby, ooba, llamacpp" data-tg-samplers="xtc_probability" id="xtc_block" class="wide100p">
14181418 <h4 class="wide100p textAlignCenter">
14191419 <label data-i18n="Exclude Top Choices (XTC)">Exclude Top Choices (XTC)</label>
14201420 <a href="https://github.com/oobabooga/text-generation-webui/pull/6335" target="_blank">
@@ -1422,7 +1422,7 @@
14221422 </a>
14231423 </h4>
14241424 <div class="flex-container flexFlowRow gap10px flexShrink">
14251425 <div data-tg-samplers="xtc_threshold" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0">
14261426 <small data-i18n="Threshold">Threshold</small>
14271427 <input class="neo-range-slider" type="range" id="xtc_threshold_textgenerationwebui" name="volume" min="0" max="0.5" step="0.01" />
14281428 <input class="neo-range-input" type="number" min="0" max="0.5" step="0.01" data-for="xtc_threshold_textgenerationwebui" id="xtc_threshold_counter_textgenerationwebui">
@@ -1435,7 +1435,7 @@
14351435 </div>
14361436 </div>
14371437
14381438 <div data-tg-type="aphrodite, mancer, ooba, koboldcpp, tabby, llamacpp, dreamgen" data-tg-samplers="dry_multiplier" id="dryBlock" class="wide100p">
14391439 <h4 class="wide100p textAlignCenter" title="DRY penalizes tokens that would extend the end of the input into a sequence that has previously occurred in the input. Set multiplier to 0 to disable." data-i18n="[title]DRY_Repetition_Penalty_desc">
14401440 <label data-i18n="DRY Repetition Penalty">DRY Repetition Penalty</label>
14411441 <a href="https://github.com/oobabooga/text-generation-webui/pull/5677" target="_blank">
@@ -1448,30 +1448,30 @@
14481448 <input class="neo-range-slider" type="range" id="dry_multiplier_textgenerationwebui" min="0" max="5" step="0.01" />
14491449 <input class="neo-range-input" type="number" min="0" max="5" step="0.01" data-for="dry_multiplier_textgenerationwebui" id="dry_multiplier_counter_textgenerationwebui">
14501450 </div>
14511451 <div data-tg-samplers="dry_base" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0" title="Controls how fast the penalty grows with increasing sequence length." data-i18n="[title]DRY_Base_desc">
14521452 <small data-i18n="Base">Base</small>
14531453 <input class="neo-range-slider" type="range" id="dry_base_textgenerationwebui" min="1" max="4" step="0.01" />
14541454 <input class="neo-range-input" type="number" min="1" max="4" step="0.01" data-for="dry_base_textgenerationwebui" id="dry_base_counter_textgenerationwebui">
14551455 </div>
14561456 <div data-tg-samplers="dry_allowed_length" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0" title="Longest sequence that can be repeated without being penalized." data-i18n="[title]DRY_Allowed_Length_desc">
14571457 <small data-i18n="Allowed Length">Allowed Length</small>
14581458 <input class="neo-range-slider" type="range" id="dry_allowed_length_textgenerationwebui" min="1" max="20" step="1" />
14591459 <input class="neo-range-input" type="number" min="1" max="20" step="1" data-for="dry_allowed_length_textgenerationwebui" id="dry_allowed_length_counter_textgenerationwebui">
14601460 </div>
14611461 <div data-tg-samplers="dry_penalty_last_n" class="alignItemsCenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0" data-tg-type="llamacpp, koboldcpp, tabby, aphrodite">
14621462 <small data-i18n="Penalty Range">Penalty Range</small>
14631463 <input class="neo-range-slider" type="range" id="dry_penalty_last_n_textgenerationwebui" min="0" max="8192" step="1" />
14641464 <input class="neo-range-input" type="number" min="0" max="8192" step="1" data-for="dry_penalty_last_n_textgenerationwebui" id="dry_penalty_last_n_counter_textgenerationwebui">
14651465 </div>
14661466 </div>
14671467 <div data-tg-samplers="dry_sequence_breakers" class="range-block marginTop5" title="Tokens across which sequence matching is not continued. Specified as a comma-separated list of quoted strings." data-i18n="[title]DRY_Sequence_Breakers_desc">
14681468 <div class="range-block-title textAlignCenter flex-container justifyCenter alignitemscenter">
14691469 <small data-i18n="Sequence Breakers">Sequence Breakers</small>
14701470 </div>
14711471 <textarea id="dry_sequence_breakers_textgenerationwebui" class="text_pole textarea_compact" name="sequence_breakers" rows="3" data-i18n="[placeholder]JSON-serialized array of strings." placeholder="JSON-serialized array of strings."></textarea>
14721472 </div>
14731473 </div>
14741474 <div data-tg-type="ooba, mancer, koboldcpp, tabby, llamacpp, aphrodite" data-tg-samplers="dynatemp" id="dynatemp_block_ooba" class="wide100p">
14751475 <h4 class="wide100p textAlignCenter">
14761476 <div class="flex-container alignitemscenter justifyCenter">
14771477 <div class="checkbox_label" for="dynatemp_textgenerationwebui">
@@ -1482,24 +1482,24 @@
14821482 </div>
14831483 </h4>
14841484 <div class="flex-container flexFlowRow alignitemscenter gap10px flexShrink">
14851485 <div data-tg-samplers="min_temp" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
14861486 <small data-i18n="Minimum Temp">Minimum Temp</small>
14871487 <input class="neo-range-slider" type="range" id="min_temp_textgenerationwebui" name="volume" min="0" max="5" step="0.01" />
14881488 <input class="neo-range-input" type="number" min="0" max="5" step="0.01" data-for="min_temp_textgenerationwebui" id="min_temp_counter_textgenerationwebui">
14891489 </div>
14901490 <div data-tg-samplers="max_temp" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
14911491 <small data-i18n="Maximum Temp">Maximum Temp</small>
14921492 <input class="neo-range-slider" type="range" id="max_temp_textgenerationwebui" name="volume" min="0" max="5" step="0.01" />
14931493 <input class="neo-range-input" type="number" min="0" max="5" step="0.01" data-for="max_temp_textgenerationwebui" id="max_temp_counter_textgenerationwebui">
14941494 </div>
14951495 <div data-tg-samplers="dynatemp_exponent" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
14961496 <small data-i18n="Exponent">Exponent</small>
14971497 <input class="neo-range-slider" type="range" id="dynatemp_exponent_textgenerationwebui" name="volume" min="0.001" max="10" step="0.001" />
14981498 <input class="neo-range-input" type="number" min="0.001" max="10" step="0.001" data-for="dynatemp_exponent_textgenerationwebui" id="dynatemp_exponent_counter_textgenerationwebui">
14991499 </div>
15001500 </div>
15011501 </div>
15021502 <div data-tg-type="ooba,infermaticai,koboldcpp,llamacpp,tabby" data-tg-samplers="mirostat_mode" id="mirostat_block_ooba" class="wide100p">
15031503 <h4 class="wide100p textAlignCenter">
15041504 <label data-i18n="Mirostat (mode=1 is only for llama.cpp)">Mirostat</label>
15051505 <div class=" fa-solid fa-circle-info opacity50p " data-i18n="[title]Mirostat_desc" title="Mirostat is a thermostat for output perplexity.&#13;Mirostat matches the output perplexity to that of the input, thus avoiding the repetition trap&#13;(where, as the autoregressive inference produces text, the perplexity of the output tends toward zero)&#13;and the confusion trap (where the perplexity diverges).&#13;For details, see the paper Mirostat: A Neural Text Decoding Algorithm that Directly Controls Perplexity by Basu et al. (2020).&#13;Mode chooses the Mirostat version. 0=disable, 1=Mirostat 1.0 (llama.cpp only), 2=Mirostat 2.0.&#13;Tau = Variability parameter for Mirostat outputs.&#13;Eta = Learning rate of Mirostat."></div>
@@ -1510,19 +1510,19 @@
15101510 <input class="neo-range-slider" type="range" id="mirostat_mode_textgenerationwebui" name="volume" min="0" max="2" step="1" />
15111511 <input class="neo-range-input" type="number" min="0" max="2" step="1" data-for="mirostat_mode_textgenerationwebui" id="mirostat_mode_counter_textgenerationwebui">
15121512 </div>
15131513 <div data-tg-samplers="mirostat_tau" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
15141514 <small data-i18n="Mirostat Tau">Tau</small>
15151515 <input class="neo-range-slider" type="range" id="mirostat_tau_textgenerationwebui" name="volume" min="0" max="20" step="0.01" />
15161516 <input class="neo-range-input" type="number" min="0" max="20" step="0.01" data-for="mirostat_tau_textgenerationwebui" id="mirostat_tau_counter_textgenerationwebui">
15171517 </div>
15181518 <div data-tg-samplers="mirostat_eta" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
15191519 <small data-i18n="Mirostat Eta">Eta</small>
15201520 <input class="neo-range-slider" type="range" id="mirostat_eta_textgenerationwebui" name="volume" min="0" max="1" step="0.01" />
15211521 <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="mirostat_eta_textgenerationwebui" id="mirostat_eta_counter_textgenerationwebui">
15221522 </div>
15231523 </div>
15241524 </div>
15251525 <div data-tg-type="ooba" data-tg-samplers="num_beams" id="beamSearchBlock" name="beamSearchBlock" class="wide100p">
15261526 <h4 class="wide100p textAlignCenter">
15271527 <label>
15281528 <span data-i18n="Beam search">Beam Search</span>
@@ -1538,7 +1538,7 @@
15381538 <input class="neo-range-slider" type="range" id="num_beams_textgenerationwebui" name="volume" min="1" max="20" step="1" />
15391539 <input class="neo-range-input" type="number" min="1" max="20" step="1" data-for="num_beams_textgenerationwebui" id="num_beams_counter_textgenerationwebui">
15401540 </div>
15411541 <div data-tg-samplers="length_penalty" class="alignitemscenter flex-container marginBot5 flexFlowColumn flexGrow flexShrink gap0">
15421542 <label>
15431543 <small data-i18n="Length Penalty">Length Penalty</small>
15441544 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Penalize sequences based on their length." title="Penalize sequences based on their length."></div>
@@ -1546,7 +1546,7 @@
15461546 <input class="neo-range-slider" type="range" id="length_penalty_textgenerationwebui" name="volume" min="-5" max="5" step="0.1" />
15471547 <input class="neo-range-input" type="number" min="-5" max="5" step="0.1" data-for="length_penalty_textgenerationwebui" id="length_penalty_counter_textgenerationwebui">
15481548 </div>
15491549 <div data-tg-samplers="early_stopping" class="">
15501550 <label class="checkbox_label" for="early_stopping_textgenerationwebui">
15511551 <input type="checkbox" id="early_stopping_textgenerationwebui" />
15521552 <small data-i18n="Early Stopping">Early Stopping</small>
@@ -1555,7 +1555,7 @@
15551555 </div>
15561556 </div>
15571557 </div>
15581558 <div data-tg-type="ooba" data-tg-samplers="penalty_alpha" id="contrastiveSearchBlock" name="contrastiveSearchBlock" class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0">
15591559 <h4 class="textAlignCenter">
15601560 <span data-i18n="Contrastive search">Contrastive Search</span>
15611561 <div class=" fa-solid fa-circle-info opacity50p " data-i18n="Contrastive_search_txt" title="A sampler that encourages diversity while maintaining coherence, by exploiting the isotropicity of the representation space of most LLMs. For details, see the paper A Contrastive Framework for Neural Text Generation by Su et al. (2022)."></div>
@@ -1571,64 +1571,64 @@
15711571 </div>
15721572 <div name="checkboxes" class="flex-container flexBasis48p justifyCenter flexGrow flexShrink ">
15731573 <div class="flex-container flexFlowColumn marginTop5">
15741574 <label data-tg-type="ooba" data-tg-samplers="do_sample" class="checkbox_label flexGrow flexShrink" for="do_sample_textgenerationwebui">
15751575 <input type="checkbox" id="do_sample_textgenerationwebui" />
15761576 <small data-i18n="Do Sample">Do Sample</small>
15771577 </label>
15781578 <label data-tg-type="ooba, tabby" data-tg-samplers="add_bos_token" class="checkbox_label flexGrow flexShrink" for="add_bos_token_textgenerationwebui">
15791579 <input type="checkbox" id="add_bos_token_textgenerationwebui" />
15801580 <small data-i18n="Add BOS Token">Add BOS Token</small>
15811581 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Add the bos_token to the beginning of prompts. Disabling this can make the replies more creative" title="Add the bos_token to the beginning of prompts. Disabling this can make the replies more creative."></div>
15821582 </label>
15831583 <label data-tg-type="ooba, llamacpp, tabby, koboldcpp, dreamgen" data-tg-samplers="ban_eos_token" class="checkbox_label flexGrow flexShrink" for="ban_eos_token_textgenerationwebui">
15841584 <input type="checkbox" id="ban_eos_token_textgenerationwebui" />
15851585 <small data-i18n="Ban EOS Token">Ban EOS Token</small>
15861586 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Ban the eos_token. This forces the model to never end the generation prematurely" title="Ban the eos_token. This forces the model to never end the generation prematurely."></div>
15871587 </label>
15881588 <label data-tg-type="vllm, aphrodite, infermaticai" data-tg-samplers="ignore_eos_token" class="checkbox_label" for="ignore_eos_token_textgenerationwebui">
15891589 <input type="checkbox" id="ignore_eos_token_textgenerationwebui" />
15901590 <small data-i18n="Ignore EOS Token">Ignore EOS Token</small>
15911591 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Ignore the EOS Token even if it generates." title="Ignore the EOS Token even if it generates."></div>
15921592 </label>
15931593 <label data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="skip_special_tokens" class="checkbox_label flexGrow flexShrink" for="skip_special_tokens_textgenerationwebui">
15941594 <input type="checkbox" id="skip_special_tokens_textgenerationwebui" />
15951595 <small data-i18n="Skip Special Tokens">Skip Special Tokens</small>
15961596 </label>
15971597 <label data-tg-type="openrouter" data-tg-samplers="include_reasoning" class="checkbox_label flexGrow flexShrink" for="include_reasoning_textgenerationwebui">
15981598 <input type="checkbox" id="include_reasoning_textgenerationwebui" />
15991599 <small data-i18n="Request Model Reasoning">Request Model Reasoning</small>
16001600 </label>
16011601 <label data-tg-type="ooba, aphrodite, tabby" data-tg-samplers="temperature_last" class="checkbox_label flexGrow flexShrink" for="temperature_last_textgenerationwebui">
16021602 <input type="checkbox" id="temperature_last_textgenerationwebui" />
16031603 <small data-i18n="Temperature Last">Temperature Last</small>
16041604 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Temperature_Last_desc" title="Use the temperature sampler last. This is almost always the sensible thing to do.&#13;When enabled: sample the set of plausible tokens first, then apply temperature to adjust their relative probabilities (technically, logits).&#13;When disabled: apply temperature to adjust the relative probabilities of ALL tokens first, then sample plausible tokens from that.&#13;Disabling Temperature Last boosts the probabilities in the tail of the distribution, which tends to amplify the chances of getting an incoherent response."></div>
16051605 </label>
16061606 <label data-tg-type="tabby" data-tg-samplers="speculative_ngram" class="checkbox_label flexGrow flexShrink" for="speculative_ngram_textgenerationwebui">
16071607 <input type="checkbox" id="speculative_ngram_textgenerationwebui" />
16081608 <small data-i18n="Speculative Ngram">Speculative Ngram</small>
16091609 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Use a different speculative decoding method without a draft model" title="Use a different speculative decoding method without a draft model.&#13;Using a draft model is preferred. Speculative ngram is not as effective."></div>
16101610 </label>
16111611 <label data-tg-type="vllm, aphrodite, infermaticai" data-tg-samplers="spaces_between_special_tokens" class="checkbox_label" for="spaces_between_special_tokens_textgenerationwebui">
16121612 <input type="checkbox" id="spaces_between_special_tokens_textgenerationwebui" />
16131613 <small data-i18n="Spaces Between Special Tokens">Spaces Between Special Tokens</small>
16141614 </label>
16151615 </div>
16161616 </div>
16171617 <div data-tg-type="mancer, ooba, koboldcpp, vllm, aphrodite, llamacpp, ollama, infermaticai, huggingface, generic" data-tg-samplers="seed" class="flex-container flexFlowColumn alignitemscenter flexBasis48p flexGrow flexShrink gap0">
16181618 <label>
16191619 <small data-i18n="Seed">Seed</small>
16201620 <div class="fa-solid fa-circle-info opacity50p " data-i18n="[title]Seed_desc" title="A random seed to use for deterministic and reproducable outputs. Set to -1 to use a random seed."></div>
16211621 </label>
16221622 <input type="number" id="seed_textgenerationwebui" class="text_pole textAlignCenter" min="-1" value="-1" />
16231623 </div>
16241624 <div data-tg-type-mode="except" data-tg-type="generic" data-tg-samplers="banned_tokens" id="banned_tokens_block_ooba" class="wide100p">
16251625 <hr class="width100p">
16261626 <div class="range-block-title title_restorable">
16271627 <div>
16281628 <strong data-i18n="Banned Tokens">Banned Tokens/Strings</strong>
16291629 <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.&#13;Unquoted text will be tokenized in the back end and banned as tokens.&#13;[token ids] will be banned as-is.&#13;Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure.&#13;Enclose text in double quotes to ban the entire string as a set.&#13;Quoted Strings and [Token ids] must be on their own line."></div>
16301630 </div>
16311631 <label data-tg-samplers="send_banned_tokens" id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
16321632 <input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
16331633 <small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
16341634 </label>
@@ -1637,7 +1637,7 @@
16371637 <div class="textAlignCenter">
16381638 <small data-i18n="Global list">Global list</small>
16391639 </div>
16401640 <div data-tg-samplers="global_banned_tokens" class="wide100p marginBot10">
16411641 <textarea id="global_banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="global_banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens&#10;[420, 69, 1337]&#10;"Some verbatim string"'></textarea>
16421642 </div>
16431643 <div class="textAlignCenter">
@@ -1648,7 +1648,7 @@
16481648 </div>
16491649 </div>
16501650 </div>
16511651 <div data-tg-samplers="logit_bias" class="range-block wide100p" id="logit_bias_block_ooba">
16521652 <div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
16531653 <h4>
16541654 <span data-i18n="Logit Bias">Logit Bias</span>
@@ -1665,7 +1665,7 @@
16651665 <div class="logit_bias_list"></div>
16661666 </div>
16671667 </div>
16681668 <div id="cfg_block_ooba" data-tg-type="ooba, tabby" data-tg-samplers="guidance_scale" class="flex-container flexFlowColumn wide100p">
16691669 <hr class="width100p">
16701670 <h4 class="textAlignCenter">
16711671 <span data-i18n="CFG">CFG</span>
@@ -1676,7 +1676,7 @@
16761676 <input class="neo-range-slider" type="range" id="guidance_scale_textgenerationwebui" name="volume" min="0.1" max="4" step="0.05">
16771677 <input class="neo-range-input" type="number" min="0.1" max="4" step="0.05" data-for="guidance_scale_textgenerationwebui" id="guidance_scale_counter_textgenerationwebui">
16781678 </div>
16791679 <div data-tg-samplers="negative_prompt" class="range-block">
16801680 <div class="alignitemscenter justifyCenter flex-container flexShrink">
16811681 <small data-i18n="Negative Prompt">Negative Prompt</small>
16821682 <div class="fa-solid fa-circle-info opacity50p" data-i18n="[title]Used if CFG Scale is unset globally, per chat or character" title="Used if CFG Scale is unset globally, per chat or character"></div>
@@ -1684,7 +1684,7 @@
16841684 <textarea id="negative_prompt_textgenerationwebui" class="wide100p text_pole textarea_compact" name="negative_prompt" rows="3" data-i18n="[placeholder]Add text here that would make the AI generate things you don't want in your outputs." placeholder="Add text here that would make the AI generate things you don't want in your outputs."></textarea>
16851685 </div>
16861686 </div>
16871687 <div id="grammar_block_ooba" data-tg-type="ooba,aphrodite,tabby" data-tg-samplers="grammar_string" class="wide100p">
16881688 <hr class="wide100p">
16891689 <h4 class="wide100p textAlignCenter">
16901690 <div class="flex-container justifyCenter alignitemscenter">
@@ -1697,7 +1697,7 @@
16971697 </h4>
16981698 <textarea id="grammar_string_textgenerationwebui" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired custom grammar" placeholder="Type in the desired custom grammar"></textarea>
16991699 </div>
17001700 <div id="json_schema_block" data-tg-type="tabby, llamacpp, aphrodite" data-tg-samplers="json_schema" class="wide100p">
17011701 <hr class="wide100p">
17021702 <h4 class="wide100p textAlignCenter"><span data-i18n="JSON Schema">JSON Schema</span>
17031703 <a href="https://json-schema.org/learn/getting-started-step-by-step" target="_blank">
@@ -1708,7 +1708,7 @@
17081708 </h4>
17091709 <textarea id="tabby_json_schema" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired JSON schema" placeholder="Type in the desired JSON schema"></textarea>
17101710 </div>
17111711 <div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" data-tg-samplers="sampler_order" class="range-block flexFlowColumn wide100p">
17121712 <hr class="wide100p">
17131713 <div class="range-block-title">
17141714 <span data-i18n="Samplers Order">Samplers Order</span>
@@ -1751,7 +1751,7 @@
17511751 <span data-i18n="Load default order">Load default order</span>
17521752 </div>
17531753 </div>
17541754 <div id="sampler_order_block_lcpp" data-tg-type="llamacpp" data-tg-samplers="samplers" class="range-block flexFlowColumn wide100p">
17551755 <hr class="wide100p">
17561756 <h4 class="range-block-title justifyCenter">
17571757 <span data-i18n="Sampler Order">Sampler Order</span>
@@ -1775,7 +1775,7 @@
17751775 <span data-i18n="Load default order">Load default order</span>
17761776 </div>
17771777 </div>
17781778 <div id="sampler_priority_block_ooba" data-tg-type="ooba" data-tg-samplers="sampler_priority" class="range-block flexFlowColumn wide100p">
17791779 <hr class="wide100p">
17801780 <h4 class="range-block-title justifyCenter">
17811781 <span data-i18n="Sampler Priority">Sampler Priority</span>
@@ -1810,7 +1810,7 @@
18101810 <span data-i18n="Load default order">Load default order</span>
18111811 </div>
18121812 </div>
18131813 <div id="sampler_priority_block_aphrodite" data-tg-type="aphrodite" data-tg-samplers="samplers_priorities" class="range-block flexFlowColumn wide100p">
18141814 <hr class="wide100p">
18151815 <h4 class="range-block-title justifyCenter">
18161816 <span data-i18n="Sampler Order">Sampler Order</span>
public/scripts/extensions/connection-manager/index.js+1 -1
@@ -47,8 +47,8 @@ const CC_COMMANDS = [
4747];
4848
4949const TC_COMMANDS = [
50- 'api',
5150 'preset',
51+ 'api',
5252 'api-url',
5353 'model',
5454 'sysprompt',
public/scripts/preset-manager.js+11 -0
@@ -27,6 +27,7 @@ import { oai_settings, openai_setting_names, openai_settings } from './openai.js
2727import { POPUP_RESULT, POPUP_TYPE, Popup } from './popup.js';
2828import { context_presets, getContextSettings, power_user } from './power-user.js';
2929import { reasoning_templates } from './reasoning.js';
30+import { getManualPresetSamplers, resetPresetSelectedSamplers, setPresetSamplersState } from './samplerSelect.js';
3031import { SlashCommand } from './slash-commands/SlashCommand.js';
3132import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js';
3233import { enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
@@ -1071,6 +1072,16 @@ export async function initPresetManager() {
10711072 return;
10721073 }
10731074
1075+ if (apiId === 'textgenerationwebui') {
1076+ const manualSamplersIterable = Object.entries(getManualPresetSamplers(oldName));
1077+
1078+ for (const [sampler, value] of manualSamplersIterable) {
1079+ setPresetSamplersState(sampler, value, newName);
1080+ }
1081+
1082+ await resetPresetSelectedSamplers(oldName, true);
1083+ }
1084+
10741085 const successToast = !presetManager.isAdvancedFormatting() ? t`Preset renamed` : t`Template renamed`;
10751086 toastr.success(successToast);
10761087 });
public/scripts/samplerSelect.js+174 -11
@@ -7,18 +7,19 @@ import { power_user } from './power-user.js';
77//import { getEventSourceStream } from './sse-stream.js';
88//import { getSortableDelay, onlyUnique } from './utils.js';
99//import { getCfgPrompt } from './cfg-scale.js';
1010import { setting_names as TGsamplerNames, showTGSamplerControls, textgenerationwebui_settings } from './textgen-settings.js';
1111import { renderTemplateAsync } from './templates.js';
1212import { Popup, POPUP_TYPE } from './popup.js';
13-
13+import { localforage } from '../lib.js';
14-
15-const TGsamplerNames = setting_names;
1614
1715const forcedOnColoring = 'color: #89db35;';
1816const forcedOffColoring = 'color: #e84f62;';
1917
2018let userDisabledSamplers, userShownSamplers;
2119
20+const textGenObjectStore = localforage.createInstance({ name: 'SillyTavern_TextCompletions' });
21+let selectedSamplers = {};
22+
2223// Goal 1: show popup with all samplers for active API
2324async function showSamplerSelectPopup() {
2425 const html = $(document.createElement('div'));
@@ -41,6 +42,12 @@ async function showSamplerSelectPopup() {
4142 userShownSamplers = [];
4243 power_user.selectSamplers.forceShown = [];
4344 power_user.selectSamplers.forceHidden = [];
45+
46+ if (main_api === 'textgenerationwebui') {
47+ $('#prioritizeManuallySelectedSamplers').toggleClass('toggleEnabled', false);
48+ await resetPresetSelectedSamplers(null, true);
49+ }
50+
4451 await validateDisabledSamplers(true);
4552 });
4653
@@ -53,7 +60,23 @@ async function showSamplerSelectPopup() {
5360 await validateDisabledSamplers();
5461 });
5562
63+ if (main_api === 'textgenerationwebui') {
64+ $('#prioritizeManuallySelectedSamplers').show();
65+ $('#prioritizeManuallySelectedSamplers').toggleClass('toggleEnabled', isSamplerManualPriorityEnabled());
66+ $('#prioritizeManuallySelectedSamplers').off('click').on('click', function () {
67+ $(this).toggleClass('toggleEnabled');
68+
69+ const isActive = $(this).hasClass('toggleEnabled');
70+
71+ toggleSamplerManualPriority(isActive);
72+ });
73+ } else {
74+ $('#prioritizeManuallySelectedSamplers').hide();
75+ $('#prioritizeManuallySelectedSamplers').off('click');
76+ }
77+
5678 await showPromise;
79+ if (main_api === 'textgenerationwebui') await savePresetSelectedSamplers();
5780}
5881
5982function setSamplerListListeners() {
@@ -180,6 +203,10 @@ function setSamplerListListeners() {
180203 const shouldDisplay = $(this).prop('checked') ? targetDisplayType : 'none';
181204 relatedDOMElement.css('display', shouldDisplay);
182205
206+ if (main_api === 'textgenerationwebui') {
207+ setPresetSamplersState(samplerName, shouldDisplay !== 'none');
208+ }
209+
183210 console.log(samplerName, relatedDOMElement.data('selectsampler'), shouldDisplay);
184211 });
185212
@@ -210,6 +237,9 @@ async function listSamplers(main_api, arrayOnly = false) {
210237 return availableSamplers;
211238 }
212239
240+ const samplersActivatedManually = (main_api === 'textgenerationwebui') ? getManualActivePresetSamplers() : [];
241+ const prioritizeManualSamplerSelect = (main_api === 'textgenerationwebui') ? isSamplerManualPriorityEnabled() : false;
242+
213243 const samplersListHTML = availableSamplers.reduce((html, sampler) => {
214244 let customColor, displayname;
215245 let targetDOMelement = $(`#${sampler}_${main_api}`);
@@ -283,8 +313,7 @@ async function listSamplers(main_api, arrayOnly = false) {
283313 displayname = 'Mirostat Block';
284314 }
285315
286-
316+ const isManuallyActivated = samplersActivatedManually.includes(sampler);
287-
288317 const isInForceHiddenArray = userDisabledSamplers.includes(sampler);
289318 const isInForceShownArray = userShownSamplers.includes(sampler);
290319 let isVisibleInDOM = isElementVisibleInDOM(targetDOMelement[0]);
@@ -295,7 +324,10 @@ async function listSamplers(main_api, arrayOnly = false) {
295324 };
296325
297326 const shouldBeChecked = () => {
298327 if (isInForceHiddenArrayprioritizeManualSamplerSelect) {
328+ return isManuallyActivated;
329+ }
330+ else if (isInForceHiddenArray) {
299331 customColor = forcedOffColoring;
300332 return false;
301333 }
@@ -307,6 +339,7 @@ async function listSamplers(main_api, arrayOnly = false) {
307339 };
308340 console.log(sampler, targetDOMelement.prop('id'), isInDefaultState(), isInForceShownArray, isInForceHiddenArray, shouldBeChecked());
309341 if (displayname === undefined) { displayname = sampler; }
342+ if (main_api === 'textgenerationwebui') setPresetSamplersState(sampler, shouldBeChecked());
310343 return html + `
311344 <div class="sampler_view_list_item wide50p flex-container">
312345 <input type="checkbox" name="${sampler}_checkbox" ${shouldBeChecked() ? 'checked' : ''}>
@@ -328,6 +361,9 @@ export async function validateDisabledSamplers(redraw = false) {
328361 return;
329362 }
330363
364+ const samplersActivatedManually = (main_api === 'textgenerationwebui') ? getManualActivePresetSamplers() : [];
365+ const prioritizeManualSamplerSelect = (main_api === 'textgenerationwebui') ? isSamplerManualPriorityEnabled() : false;
366+
331367 for (const sampler of APISamplers) {
332368 let relatedDOMElement = $(`#${sampler}_${main_api}`).parent();
333369 let targetDisplayType = 'flex';
@@ -400,6 +436,7 @@ export async function validateDisabledSamplers(redraw = false) {
400436 relatedDOMElement = $('#smoothingBlock');
401437 }
402438
439+
403440 if (power_user?.selectSamplers?.forceHidden.includes(sampler)) {
404441 //default handling for standard sliders
405442 relatedDOMElement.data('selectsampler', 'hidden');
@@ -417,20 +454,147 @@ export async function validateDisabledSamplers(redraw = false) {
417454 relatedDOMElement.css('display', 'none');
418455 }
419456 }
457+
458+ if (prioritizeManualSamplerSelect) {
459+ const isManuallyActivated = samplersActivatedManually.includes(sampler);
460+ relatedDOMElement.css('display', isManuallyActivated ? targetDisplayType : 'none');
461+ }
462+ }
463+
420464 if (redraw) {
465+ if (main_api === 'textgenerationwebui') showTGSamplerControls();
466+
421467 let samplersHTML = await listSamplers(main_api);
422468 $('#apiSamplersList').empty().append(samplersHTML.toString());
423469 setSamplerListListeners();
424470 }
425471
426472 await saveSettingsDebounced();
427-
428- }
429473}
430474
475+/**
476+ * Initializes the configuration object for manually selected samplers.
477+ */
478+export async function loadPresetSelectedSamplers() {
479+ try {
480+ console.debug('Text Completions: loading selected samplers');
481+ selectedSamplers = await textGenObjectStore.getItem('selectedSamplers') || {};
482+ } catch (error) {
483+ console.log('Text Completions: unable to load selected samplers, using default samplers', error);
484+ selectedSamplers = {};
485+ }
486+}
487+
488+/**
489+ * Synchronizes the local forage instance with the selected samplers configuration object.
490+ */
491+export async function savePresetSelectedSamplers() {
492+ try {
493+ console.debug('Text Completions: saving selected samplers');
494+ await textGenObjectStore.setItem('selectedSamplers', selectedSamplers);
495+ } catch (error) {
496+ console.log('Text Completions: unable to save selected samplers', error);
497+ }
498+}
499+
500+/**
501+ * Resets the selected samplers configuration object from the local forage instance.
502+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
503+ * @param {boolean} silent Suppresses the toastr message confirming that the data was deleted.
504+ */
505+export async function resetPresetSelectedSamplers(presetName = '', silent = false) {
506+ try {
507+ if (!textgenerationwebui_settings?.preset && !presetName) return;
508+ if (!presetName) presetName = textgenerationwebui_settings.preset;
509+ if (!selectedSamplers[presetName]) return;
510+
511+ console.debug('Text Completions: resetting selected samplers');
512+ delete selectedSamplers[presetName];
513+ await savePresetSelectedSamplers();
514+ if (!silent) toastr.success('Selected samplers cleared.');
515+ } catch (error) {
516+ console.log('Text Completions: unable to reset selected preset samplers', error);
517+ }
518+}
519+
520+/**
521+ * Saves the visibility state for selected samplers into the configuration object.
522+ * @param {string} samplerName Target sampler key name
523+ * @param {string|boolean} state Visibility state of the target sampler
524+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
525+ * @returns void
526+ */
527+export function setPresetSamplersState(samplerName, state, presetName = '') {
528+ if (!textgenerationwebui_settings?.preset && !presetName) return;
529+ if (!presetName) presetName = textgenerationwebui_settings.preset;
530+ if (!selectedSamplers[presetName]) selectedSamplers[presetName] = {};
531+
532+ const presetSamplers = selectedSamplers[presetName];
533+ presetSamplers[samplerName] = String(state) === 'true';
534+}
535+
536+/**
537+ * Returns the local forage object belonging to the active/selected TC preset
538+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
539+ * @returns {object} Full localforage object with manual selections
540+ */
541+export function getManualPresetSamplers(presetName = '') {
542+ if (!textgenerationwebui_settings?.preset && !presetName) return {};
543+ if (!presetName) presetName = textgenerationwebui_settings.preset;
544+ if (!selectedSamplers[presetName]) selectedSamplers[presetName] = {};
545+
546+ return selectedSamplers[presetName];
547+}
548+
549+/**
550+ * Returns the key names of all the preset samplers activated manually.
551+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
552+ * @returns {string[]} Array of sampler key names
553+ */
554+export function getManualActivePresetSamplers(presetName = '') {
555+ if (!textgenerationwebui_settings?.preset && !presetName) return [];
556+ if (!presetName) presetName = textgenerationwebui_settings.preset;
557+ if (!selectedSamplers[presetName]) selectedSamplers[presetName] = {};
558+
559+ try {
560+ const presetSamplers = Object.entries(selectedSamplers[presetName]);
561+
562+ return presetSamplers
563+ .filter(([key, val]) => val === true && key !== 'st_manual_priority')
564+ .map(([key, val]) => key);
565+ } catch (error) {
566+ console.log('Text Completions: unable to fetch active preset samplers', error);
567+ return [];
568+ }
569+}
570+
571+/**
572+ * @param {string|boolean} state Target state of the feature
573+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
574+ * @returns void
575+ */
576+export function toggleSamplerManualPriority(state = false, presetName = '') {
577+ if (!textgenerationwebui_settings?.preset && !presetName) return;
578+ if (!presetName) presetName = textgenerationwebui_settings.preset;
579+ if (!selectedSamplers[presetName]) selectedSamplers[presetName] = {};
580+
581+ const presetSamplers = selectedSamplers[presetName];
582+ presetSamplers.st_manual_priority = String(state) === 'true';
583+}
584+
585+/**
586+ * @param {string?} presetName Name of the target preset - It picks the current active TC preset name by default
587+ * @returns {boolean}
588+ */
589+export function isSamplerManualPriorityEnabled(presetName = '') {
590+ if (!textgenerationwebui_settings?.preset && !presetName) return false;
591+ if (!presetName) presetName = textgenerationwebui_settings.preset;
592+ if (!selectedSamplers[presetName]) selectedSamplers[presetName] = {};
593+
594+ return selectedSamplers[presetName]?.st_manual_priority ?? false;
595+}
431596
432597export async function initCustomSelectedSamplers() {
433-
434598 userDisabledSamplers = power_user?.selectSamplers?.forceHidden || [];
435599 userShownSamplers = power_user?.selectSamplers?.forceShown || [];
436600 power_user.selectSamplers = {};
@@ -438,7 +602,6 @@ export async function initCustomSelectedSamplers() {
438602 power_user.selectSamplers.forceShown = userShownSamplers;
439603 await saveSettingsDebounced();
440604 $('#samplerSelectButton').off('click').on('click', showSamplerSelectPopup);
441-
442605}
443606
444607// Goal 4: filter hidden samplers from API output
public/scripts/templates/samplerSelector.html+7 -1
@@ -1,10 +1,16 @@
11<div class="title_restorable flexFlowColumn alignItemsBaseline">
22 <div class="flex-container justifyCenterjustifySpaceBetween alignItemsBaseline wide100p">
33 <h3 data-i18n="Sampler Select">Sampler Select</h3>
44 <div class="flex-container alignItemsBaseline">
55 <div id="resetSelectedSamplers" class="menu_button menu_button_icon" data-i18n="[title]Reset custom sampler selection" title="Reset custom sampler selection">
66 <i class="fa-solid fa-recycle"></i>
7+ <span data-i18n="Reset">Reset</span>
78 </div>
9+ <div id="prioritizeManuallySelectedSamplers" class="menu_button menu_button_icon" data-i18n="[title]Prioritize showing samplers manually selected from this popup." title="Prioritize showing samplers manually selected from this popup.">
10+ <i class="fa-solid fa-lock"></i>
11+ <span data-i18n="Prioritize">Prioritize</span>
12+ </div>
13+ <div class="margin5 fa-solid fa-exclamation-circle" data-i18n="[title]Toggle on to force the samplers selected in this menu to be shown when switching to this preset. By default, SillyTavern automatically selects samplers used or needed by the selected API Type in the API Connections panel." title="Toggle on to force the samplers selected in this menu to be shown when switching to this preset. By default, SillyTavern automatically selects samplers used or needed by the selected API Type in the API Connections panel."></div>
814 </div>
915 <!--<div class="flex-container alignItemsBaseline">
1016 <div class="menu_button menu_button_icon" title="Create a new sampler">
public/scripts/textgen-settings.js+43 -2
@@ -20,6 +20,7 @@ import { autoSelectInstructPreset, selectContextPreset, selectInstructPreset } f
2020import { BIAS_CACHE, createNewLogitBiasEntry, displayLogitBias, getLogitBiasListResult } from './logit-bias.js';
2121
2222import { power_user, registerDebugFunction } from './power-user.js';
23+import { getManualActivePresetSamplers, isSamplerManualPriorityEnabled, loadPresetSelectedSamplers } from './samplerSelect.js';
2324import { SECRET_KEYS, writeSecret } from './secrets.js';
2425import { getEventSourceStream } from './sse-stream.js';
2526import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, loadAphroditeModels, loadDreamGenModels, loadFeatherlessModels, loadGenericModels, loadInfermaticAIModels, loadMancerModels, loadOllamaModels, loadOpenRouterModels, loadTabbyModels, loadTogetherAIModels, loadVllmModels } from './textgen-models.js';
@@ -230,6 +231,7 @@ const settings = {
230231
231232export {
232233 settings as textgenerationwebui_settings,
234+ showSamplerControls as showTGSamplerControls,
233235};
234236
235237export let textgenerationwebui_banned_in_macros = [];
@@ -370,6 +372,7 @@ async function selectPreset(name) {
370372 setSettingByName(name, value, true);
371373 }
372374 setGenerationParamsFromPreset(preset);
375+ showSamplerControls(null, true);
373376 BIAS_CACHE.delete(BIAS_KEY);
374377 displayLogitBias(preset.logit_bias, BIAS_KEY);
375378 saveSettingsDebounced();
@@ -569,7 +572,8 @@ export function loadTextGenSettings(data, loadedSettings) {
569572
570573 $('#textgen_type').val(settings.type);
571574 $('#openrouter_providers_text').val(settings.openrouter_providers).trigger('change');
572575 showTypeSpecificControlsloadPresetSelectedSamplers(settings.type);
576+ showSamplerControls();
573577 BIAS_CACHE.delete(BIAS_KEY);
574578 displayLogitBias(settings.logit_bias, BIAS_KEY);
575579
@@ -775,6 +779,8 @@ async function getStatusTextgen() {
775779}
776780
777781export function initTextGenSettings() {
782+ loadPresetSelectedSamplers();
783+
778784 $('#send_banned_tokens_textgenerationwebui').on('change', function () {
779785 const checked = !!$(this).prop('checked');
780786 toggleBannedStringsKillSwitch(checked,
@@ -902,7 +908,7 @@ export function initTextGenSettings() {
902908 }
903909 }
904910
905911 showTypeSpecificControlsshowSamplerControls(type);
906912 setOnlineStatus('no_connection');
907913 BIAS_CACHE.delete(BIAS_KEY);
908914
@@ -1069,6 +1075,41 @@ export function initTextGenSettings() {
10691075 });
10701076}
10711077
1078+/**
1079+ * Hides and shows preset samplers from the left panel.
1080+ * @param {string?} apiType API Type selected in API Connections - Currently selected one by default
1081+ * @param {boolean?} isPresetSwitch Wheter the trigger comes from a preset switch - false by default
1082+ * @returns void
1083+ */
1084+function showSamplerControls(apiType = null, isPresetSwitch = false) {
1085+ const prioritizeManualSamplerSelect = isSamplerManualPriorityEnabled();
1086+
1087+ if (isPresetSwitch && !prioritizeManualSamplerSelect) return;
1088+
1089+ $('#textgenerationwebui_api-settings [data-tg-samplers]:not([data-tg-type])').each(function() {
1090+ $(this).show();
1091+ });
1092+
1093+ showTypeSpecificControls(apiType ?? settings.type);
1094+
1095+ const samplersActivatedManually = getManualActivePresetSamplers();
1096+
1097+ if (!samplersActivatedManually?.length || !prioritizeManualSamplerSelect) return;
1098+
1099+ $('#textgenerationwebui_api-settings [data-tg-samplers]').each(function() {
1100+ const tgSamplers = $(this).attr('data-tg-samplers').split(',').map(x => x.trim()).filter(str => str !== '');
1101+
1102+ for (const tgSampler of tgSamplers) {
1103+ if (samplersActivatedManually.includes(tgSampler)) {
1104+ $(this).show();
1105+ return;
1106+ } else {
1107+ $(this).hide();
1108+ }
1109+ }
1110+ });
1111+}
1112+
10721113function showTypeSpecificControls(type) {
10731114 $('[data-tg-type]').each(function () {
10741115 const mode = String($(this).attr('data-tg-type-mode') ?? '').toLowerCase().trim();