diff --git a/static/koboldai.css b/static/koboldai.css index 750a82e4..7eb7609f 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -235,11 +235,6 @@ border-top-right-radius: var(--tabs_rounding); margin: 2px; } -#biasing { - margin-left: 5px; - margin-right: 5px; -} - .setting_container.var_sync_alt_system_alt_gen[system_alt_gen="true"] { display: none; } @@ -664,40 +659,40 @@ border-top-right-radius: var(--tabs_rounding); } /* Bias */ -#biases_label { - cursor: pointer; +#biasing { + padding: 0px 10px; } -.bias { - display: grid; - grid-template-areas: "phrase percent max"; - grid-template-columns: auto 100px 100px; +.bias_card { + background-color: var(--setting_background); + padding: 8px; +} + +.bias_top { + display: flex; + justify-content: space-between; +} + +.bias_top > .close_button { + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + margin-left: 7px; +} + +.bias_card input { + width: 100%; + border: none; } .bias_phrase { - grid-area: phrase; - margin-right: 5px; + height: 36px; } -.bias_phrase input { - width: 100%; -} - -.bias_score { - grid-area: percent; - margin-right: 5px; -} - -.bias_comp_threshold { - grid-area: max; - margin-right: 5px; -} - -.bias_slider { - display: grid; - grid-template-areas: "bar bar bar" - "min cur max"; - grid-template-columns: 33px 34px 33px; +.bias_slider_labels { + display: flex; + justify-content: space-between; } .bias_slider_bar { diff --git a/static/koboldai.js b/static/koboldai.js index 5485c22e..ead78017 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -3633,42 +3633,49 @@ function options_on_right(data) { } } +function makeBiasCard(phrase, score, compThreshold) { + function updateLabel(input) { + input.closest(".bias_slider").querySelector(".bias_slider_cur").innerText = input.value; + } + + const biasContainer = $el("#biasing"); + const biasCard = $el(".bias_card.template").cloneNode(true); + biasCard.classList.remove("template"); + + const phraseInput = biasCard.querySelector(".bias_phrase"); + const scoreInput = biasCard.querySelector(".bias_score input"); + const compThresholdInput = biasCard.querySelector(".bias_comp_threshold input"); + + phraseInput.value = phrase; + + scoreInput.value = score; + scoreInput.addEventListener("input", function() { updateLabel(this) }); + updateLabel(scoreInput); + + compThresholdInput.value = compThreshold; + compThresholdInput.addEventListener("input", function() { updateLabel(this) }); + updateLabel(compThresholdInput); + + biasContainer.appendChild(biasCard); +} + function do_biases(data) { - //console.log(data); //clear out our old bias lines - let bias_list = Object.assign([], document.getElementsByClassName("bias")); - for (item of bias_list) { - //console.log(item); + for (item of document.getElementsByClassName("bias_card")) { + if (item.classList.contains("template")) continue; item.parentNode.removeChild(item); } //add our bias lines for (const [key, value] of Object.entries(data.value)) { - bias_line = document.getElementById("empty_bias").cloneNode(true); - bias_line.id = ""; - bias_line.classList.add("bias"); - bias_line.querySelector(".bias_phrase").querySelector("input").value = key; - bias_line.querySelector(".bias_score").querySelector("input").value = value[0]; - update_bias_slider_value(bias_line.querySelector(".bias_score").querySelector("input")); - bias_line.querySelector(".bias_comp_threshold").querySelector("input").value = value[1]; - update_bias_slider_value(bias_line.querySelector(".bias_comp_threshold").querySelector("input")); - document.getElementById('biasing').append(bias_line); + makeBiasCard(key, value[0], value[1]); } //add another bias line if this is the phrase and it's not blank - bias_line = document.getElementById("empty_bias").cloneNode(true); - bias_line.id = ""; - bias_line.classList.add("bias"); - bias_line.querySelector(".bias_phrase").querySelector("input").value = ""; - bias_line.querySelector(".bias_phrase").querySelector("input").id = "empty_bias_phrase"; - bias_line.querySelector(".bias_score").querySelector("input").value = 1; - bias_line.querySelector(".bias_comp_threshold").querySelector("input").value = 50; - document.getElementById('biasing').append(bias_line); + const templateBiasCard = makeBiasCard("", 1, 50); + // bias_line.querySelector(".bias_phrase").querySelector("input").id = "empty_bias_phrase"; } -function update_bias_slider_value(slider) { - slider.parentElement.parentElement.querySelector(".bias_slider_cur").textContent = slider.value; -} function distortColor(rgb) { // rgb are 0..255, NOT NORMALIZED!!!!!! diff --git a/templates/settings flyout.html b/templates/settings flyout.html index 1eb85110..a4576113 100644 --- a/templates/settings flyout.html +++ b/templates/settings flyout.html @@ -242,14 +242,8 @@
Influence the likelihood for the AI to output certain phrases.
-
-
Phrase
-
Score
-
- Completion Threshold - help_icon -
-
+ +
diff --git a/templates/templates.html b/templates/templates.html index 8a60b7b7..01d7a598 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -112,29 +112,35 @@ -
-
- +
+
+ + close
-
-
-
- -
+ + Score +
+
+ +
+
-50
0
50
-
-
-
- -
+ + + Completion Threshold + help_icon + +
+
+ +
+
0
10
10