From add108b8216820a38a49e89a04c055c17d77d088 Mon Sep 17 00:00:00 2001 From: AlpinDale Date: Sat, 7 Dec 2024 12:36:10 +0000 Subject: [PATCH] fix the JS issue where both ooba and aphro were using the same container ID --- public/index.html | 2 +- public/scripts/textgen-settings.js | 34 ++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index 5d54b7d48..d8a679675 100644 --- a/public/index.html +++ b/public/index.html @@ -1783,7 +1783,7 @@
Aphrodite only. Determines the order of samplers.
-
+
DRY
Penalties
No Repeat Ngram
diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index 21c4202a8..e5d018b74 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -571,6 +571,15 @@ function sortOobaItemsByOrder(orderArray) { }); } +function sortAphroditeItemsByOrder(orderArray) { + const $container = $('#sampler_priority_container_aphrodite'); + + orderArray.forEach((name) => { + const $item = $container.find(`[data-name="${name}"]`).detach(); + $container.append($item); + }); +} + jQuery(function () { $('#koboldcpp_order').sortable({ delay: getSortableDelay(), @@ -624,6 +633,19 @@ jQuery(function () { }, }); + $('#sampler_priority_container_aphrodite').sortable({ + delay: getSortableDelay(), + stop: function () { + const order = []; + $('#sampler_priority_container_aphrodite').children().each(function () { + order.push($(this).data('name')); + }); + settings.samplers_priorities = order; + console.log('Samplers reordered:', settings.samplers_priorities); + saveSettingsDebounced(); + }, + }); + $('#tabby_json_schema').on('input', function () { const json_schema_string = String($(this).val()); @@ -643,9 +665,9 @@ jQuery(function () { }); $('#aphrodite_default_order').on('click', function () { - sortOobaItemsByOrder(APHRODITE_DEFAULT_ORDER); - settings.samplers_priorties = APHRODITE_DEFAULT_ORDER; - console.log('Default samplers order loaded:', settings.samplers_priorties); + sortAphroditeItemsByOrder(APHRODITE_DEFAULT_ORDER); + settings.samplers_priorities = APHRODITE_DEFAULT_ORDER; + console.log('Default samplers order loaded:', settings.samplers_priorities); saveSettingsDebounced(); }); @@ -860,8 +882,8 @@ function setSettingByName(setting, value, trigger) { if ('samplers_priority' === setting) { value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); - sortOobaItemsByOrder(value); - settings.samplers_priorties = value; + sortAphroditeItemsByOrder(value); + settings.samplers_priorities = value; return; } @@ -1289,7 +1311,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, 'nsigma': settings.nsigma, 'custom_token_bans': toIntArray(banned_tokens), 'no_repeat_ngram_size': settings.no_repeat_ngram_size, - 'sampler_priority': settings.samplers_priorties, + 'sampler_priority': settings.type === APHRODITE ? settings.samplers_priorities : undefined, }; if (settings.type === OPENROUTER) {