fix the JS issue where both ooba and aphro were using the same container ID

This commit is contained in:
AlpinDale 2024-12-07 12:36:10 +00:00
parent a1115ab4ff
commit add108b821
2 changed files with 29 additions and 7 deletions

View File

@ -1783,7 +1783,7 @@
<div class="toggle-description widthUnset" data-i18n="Aphrodite only. Determines the order of samplers. Skew is always applied post-softmax, so it's not included here."> <div class="toggle-description widthUnset" data-i18n="Aphrodite only. Determines the order of samplers. Skew is always applied post-softmax, so it's not included here.">
Aphrodite only. Determines the order of samplers. Aphrodite only. Determines the order of samplers.
</div> </div>
<div id="sampler_priority_container" class="prompt_order"> <div id="sampler_priority_container_aphrodite" class="prompt_order">
<div data-name="dry" draggable="true"><span>DRY</span><small></small></div> <div data-name="dry" draggable="true"><span>DRY</span><small></small></div>
<div data-name="penalties" draggable="true"><span>Penalties</span><small></small></div> <div data-name="penalties" draggable="true"><span>Penalties</span><small></small></div>
<div data-name="no_repeat_ngram" draggable="true"><span>No Repeat Ngram</span><small></small></div> <div data-name="no_repeat_ngram" draggable="true"><span>No Repeat Ngram</span><small></small></div>

View File

@ -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 () { jQuery(function () {
$('#koboldcpp_order').sortable({ $('#koboldcpp_order').sortable({
delay: getSortableDelay(), 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 () { $('#tabby_json_schema').on('input', function () {
const json_schema_string = String($(this).val()); const json_schema_string = String($(this).val());
@ -643,9 +665,9 @@ jQuery(function () {
}); });
$('#aphrodite_default_order').on('click', function () { $('#aphrodite_default_order').on('click', function () {
sortOobaItemsByOrder(APHRODITE_DEFAULT_ORDER); sortAphroditeItemsByOrder(APHRODITE_DEFAULT_ORDER);
settings.samplers_priorties = APHRODITE_DEFAULT_ORDER; settings.samplers_priorities = APHRODITE_DEFAULT_ORDER;
console.log('Default samplers order loaded:', settings.samplers_priorties); console.log('Default samplers order loaded:', settings.samplers_priorities);
saveSettingsDebounced(); saveSettingsDebounced();
}); });
@ -860,8 +882,8 @@ function setSettingByName(setting, value, trigger) {
if ('samplers_priority' === setting) { if ('samplers_priority' === setting) {
value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER; value = Array.isArray(value) ? value : APHRODITE_DEFAULT_ORDER;
insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value); insertMissingArrayItems(APHRODITE_DEFAULT_ORDER, value);
sortOobaItemsByOrder(value); sortAphroditeItemsByOrder(value);
settings.samplers_priorties = value; settings.samplers_priorities = value;
return; return;
} }
@ -1289,7 +1311,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
'nsigma': settings.nsigma, 'nsigma': settings.nsigma,
'custom_token_bans': toIntArray(banned_tokens), 'custom_token_bans': toIntArray(banned_tokens),
'no_repeat_ngram_size': settings.no_repeat_ngram_size, '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) { if (settings.type === OPENROUTER) {