let loose the Mad Labs

This commit is contained in:
RossAscends 2023-11-10 16:17:38 +09:00
parent 2f5e7778cc
commit dfb8a85eed
3 changed files with 94 additions and 1 deletions

View File

@ -121,6 +121,7 @@
<div data-i18n="clickslidertips" class="toggle-description wide100p editable-slider-notification">
Click slider numbers to input manually.
</div>
<div id="labModeWarning" class="redWarningBG textAlignCenter">MAD LAB MODE ON</div>
<a href="https://docs.sillytavern.app/usage/common-settings/" target="_blank" title="Documentation on sampling parameters.">
<span name="samplerHelpButton" class="note-link-span topRightInset fa-solid fa-circle-question"></span>
</a>
@ -2702,6 +2703,10 @@
<input id="enableZenSliders" type="checkbox" />
<span data-i18n="Zen Sliders">Zen Sliders</span>
</label>
<label data-newbie-hidden for="enableLabMode" class="checkbox_label">
<input id="enableLabMode" type="checkbox" />
<span data-i18n="Mad Lab Mode">Mad Lab Mode</span>
</label>
<label data-newbie-hidden for="messageTimerEnabled" class="checkbox_label">
<input id="messageTimerEnabled" type="checkbox" />
<span data-i18n="Message Timer">Message Timer</span>
@ -4618,4 +4623,4 @@
</script>
</body>
</html>
</html>

View File

@ -9010,6 +9010,13 @@ jQuery(async function () {
const closestStep = Math.round(rawStepCompare)
const closestStepRaw = (closestStep) * masterStep
//yolo anything for Lab Mode
if (power_user.enableLabMode) {
console.log($(masterElement).attr('id'), myValue)
$(masterElement).val(myValue).trigger('input')
return
}
//if text box val is not a number, reset slider val to its previous and wait for better input
if (Number.isNaN(myValue)) {
console.warn('Label input is not a valid number. Resetting the value to match slider', myText);

View File

@ -166,6 +166,7 @@ let power_user = {
message_token_count_enabled: false,
expand_message_actions: false,
enableZenSliders: false,
enableLabMode: false,
prefer_character_prompt: true,
prefer_character_jailbreak: true,
quick_continue: false,
@ -256,6 +257,7 @@ const storage_keys = {
message_token_count_enabled: 'MessageTokenCountEnabled',
expand_message_actions: 'ExpandMessageActions',
enableZenSliders: 'enableZenSliders',
enableLabMode: 'enableLabMode',
};
const contextControls = [
@ -424,13 +426,62 @@ function switchMessageActions() {
$('.extraMesButtons, .extraMesButtonsHint').removeAttr('style');
}
var originalSliderValues = []
async function switchLabMode() {
if (power_user.enableZenSliders) {
//force disable ZenSliders for Lab Mode
$("#enableZenSliders").trigger('click')
}
await delay(100)
const value = localStorage.getItem(storage_keys.enableLabMode);
power_user.enableLabMode = value === null ? false : value == "true";
$("body").toggleClass("enableLabMode", power_user.enableLabMode);
$("#enableLabMode").prop("checked", power_user.enableLabMode);
if (power_user.enableLabMode) {
//save all original slider values into an array
$("#advanced-ai-config-block input").each(function () {
let id = $(this).attr('id')
let min = $(this).attr('min')
let max = $(this).attr('max')
let step = $(this).attr('step')
originalSliderValues.push({ id, min, max, step });
})
//console.log(originalSliderValues)
//remove limits on all inputs and hide sliders
$("#advanced-ai-config-block input")
.attr('min', '-99999')
.attr('max', '99999')
.attr('step', '0.001')
$("#labModeWarning").show()
//$("#advanced-ai-config-block input[type='range']").hide()
} else {
//re apply the original sliders values to each input
originalSliderValues.forEach(function (slider) {
$("#" + slider.id)
.attr('min', slider.min)
.attr('max', slider.max)
.attr('step', slider.step)
.trigger('input')
});
$("#advanced-ai-config-block input[type='range']").show()
$("#labModeWarning").hide()
}
}
async function switchZenSliders() {
await delay(100)
const value = localStorage.getItem(storage_keys.enableZenSliders);
power_user.enableZenSliders = value === null ? false : value == "true";
$("body").toggleClass("enableZenSliders", power_user.enableZenSliders);
$("#enableZenSliders").prop("checked", power_user.enableZenSliders);
if (power_user.enableZenSliders) {
$("#pro-settings-block input[type='number']").hide();
//hide number inputs that are not 'seed' inputs
@ -972,6 +1023,13 @@ async function applyTheme(name) {
switchMessageActions();
}
},
{
key: 'enableLabMode',
action: async () => {
localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode));
switchMessageActions();
}
},
{
key: 'hotswap_enabled',
action: async () => {
@ -1087,6 +1145,7 @@ function loadPowerUserSettings(settings, data) {
const mesIDDisplay = localStorage.getItem(storage_keys.mesIDDisplay_enabled);
const expandMessageActions = localStorage.getItem(storage_keys.expand_message_actions);
const enableZenSliders = localStorage.getItem(storage_keys.enableZenSliders);
const enableLabMode = localStorage.getItem(storage_keys.enableLabMode);
power_user.fast_ui_mode = fastUi === null ? true : fastUi == "true";
power_user.movingUI = movingUI === null ? false : movingUI == "true";
power_user.noShadows = noShadows === null ? false : noShadows == "true";
@ -1096,6 +1155,7 @@ function loadPowerUserSettings(settings, data) {
power_user.mesIDDisplay_enabled = mesIDDisplay === null ? true : mesIDDisplay == "true";
power_user.expand_message_actions = expandMessageActions === null ? true : expandMessageActions == "true";
power_user.enableZenSliders = enableZenSliders === null ? false : enableZenSliders == "true";
power_user.enableLabMode = enableLabMode === null ? false : enableLabMode == "true";
power_user.avatar_style = Number(localStorage.getItem(storage_keys.avatar_style) ?? avatar_styles.ROUND);
//power_user.chat_display = Number(localStorage.getItem(storage_keys.chat_display) ?? chat_styles.DEFAULT);
power_user.chat_width = Number(localStorage.getItem(storage_keys.chat_width) ?? 50);
@ -1178,6 +1238,7 @@ function loadPowerUserSettings(settings, data) {
$("#prefer_character_prompt").prop("checked", power_user.prefer_character_prompt);
$("#prefer_character_jailbreak").prop("checked", power_user.prefer_character_jailbreak);
$("#enableZenSliders").prop('checked', power_user.enableZenSliders).trigger('input');
$("#enableLabMode").prop('checked', power_user.enableLabMode).trigger('input');
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
$(`#chat_display option[value=${power_user.chat_display}]`).attr("selected", true).trigger('change');
$('#chat_width_slider').val(power_user.chat_width);
@ -1598,6 +1659,7 @@ async function saveTheme() {
message_token_count_enabled: power_user.message_token_count_enabled,
expand_message_actions: power_user.expand_message_actions,
enableZenSliders: power_user.enableZenSliders,
enableLabMode: power_user.enableLabMode,
hotswap_enabled: power_user.hotswap_enabled,
custom_css: power_user.custom_css,
@ -2591,12 +2653,31 @@ $(document).ready(() => {
});
$("#enableZenSliders").on("input", function () {
if (power_user.enableLabMode) {
//disallow zenSliders while Lab Mode is active
toastr.warning('ZenSliders not allowed in Mad Lab Mode')
$(this).prop('checked', false);
return
}
const value = !!$(this).prop('checked');
power_user.enableZenSliders = value;
localStorage.setItem(storage_keys.enableZenSliders, Boolean(power_user.enableZenSliders));
switchZenSliders();
});
$("#enableLabMode").on("input", function () {
if (power_user.enableZenSliders) {
//disallow Lab Mode if ZenSliders are active
toastr.warning('Mad Lab Mode not allowed while ZenSliders are active')
$(this).prop('checked', false);
return
}
const value = !!$(this).prop('checked');
power_user.enableLabMode = value;
localStorage.setItem(storage_keys.enableLabMode, Boolean(power_user.enableLabMode));
switchLabMode();
});
$("#mesIDDisplayEnabled").on("input", function () {
const value = !!$(this).prop('checked');
power_user.mesIDDisplay_enabled = value;