Add Samplers menu
This commit is contained in:
parent
4c7d6f42d9
commit
6231106f95
12
aiserver.py
12
aiserver.py
|
@ -2873,6 +2873,8 @@ def get_message(msg):
|
|||
elif(msg['cmd'] == 'uslistrequest'):
|
||||
unloaded, loaded = getuslist()
|
||||
emit('from_server', {'cmd': 'buildus', 'data': {"unloaded": unloaded, "loaded": loaded}})
|
||||
elif(msg['cmd'] == 'samplerlistrequest'):
|
||||
emit('from_server', {'cmd': 'buildsamplers', 'data': vars.sampler_order})
|
||||
elif(msg['cmd'] == 'usloaded'):
|
||||
vars.userscripts = []
|
||||
for userscript in msg['data']:
|
||||
|
@ -2886,6 +2888,16 @@ def get_message(msg):
|
|||
load_lua_scripts()
|
||||
unloaded, loaded = getuslist()
|
||||
sendUSStatItems()
|
||||
elif(msg['cmd'] == 'samplers'):
|
||||
sampler_order = msg["data"]
|
||||
if(not isinstance(sampler_order, list)):
|
||||
raise ValueError(f"Sampler order must be a list, but got a {type(sampler_order)}")
|
||||
if(len(sampler_order) != len(vars.sampler_order)):
|
||||
raise ValueError(f"Sampler order must be a list of length {len(vars.sampler_order)}, but got a list of length {len(sampler_order)}")
|
||||
if(not all(isinstance(e, int) for e in sampler_order)):
|
||||
raise ValueError(f"Sampler order must be a list of ints, but got a list with at least one non-int element")
|
||||
vars.sampler_order = sampler_order
|
||||
settingschanged()
|
||||
elif(msg['cmd'] == 'loadselect'):
|
||||
vars.loadselect = msg["data"]
|
||||
elif(msg['cmd'] == 'spselect'):
|
||||
|
|
|
@ -20,6 +20,7 @@ var button_settings;
|
|||
var button_format;
|
||||
var button_softprompt;
|
||||
var button_userscripts;
|
||||
var button_samplers;
|
||||
var button_mode;
|
||||
var button_mode_label;
|
||||
var button_send;
|
||||
|
@ -109,6 +110,9 @@ var do_clear_ent = false;
|
|||
// Whether or not an entry in the Userscripts menu is being dragged
|
||||
var us_dragging = false;
|
||||
|
||||
// Whether or not an entry in the Samplers menu is being dragged
|
||||
var samplers_dragging = false;
|
||||
|
||||
// Display vars
|
||||
var allowtoggle = false;
|
||||
var formatcount = 0;
|
||||
|
@ -976,6 +980,16 @@ function hideUSPopup() {
|
|||
spcontent.html("");
|
||||
}
|
||||
|
||||
function showSamplersPopup() {
|
||||
samplerspopup.removeClass("hidden");
|
||||
samplerspopup.addClass("flex");
|
||||
}
|
||||
|
||||
function hideSamplersPopup() {
|
||||
samplerspopup.removeClass("flex");
|
||||
samplerspopup.addClass("hidden");
|
||||
}
|
||||
|
||||
function buildLoadList(ar) {
|
||||
disableButtons([load_accept]);
|
||||
loadcontent.html("");
|
||||
|
@ -1109,6 +1123,29 @@ function buildUSList(unloaded, loaded) {
|
|||
}
|
||||
}
|
||||
|
||||
function buildSamplerList(samplers) {
|
||||
samplerslist.html("");
|
||||
showSamplersPopup();
|
||||
var i;
|
||||
var samplers_lookup_table = [
|
||||
"Top-k Sampling",
|
||||
"Top-a Sampling",
|
||||
"Top-p Sampling",
|
||||
"Tail-free Sampling",
|
||||
"Typical Sampling",
|
||||
"Temperature",
|
||||
]
|
||||
for(i=0; i<samplers.length; i++) {
|
||||
samplerslist.append("<div class=\"flex\">\
|
||||
<div class=\"samplerslistitem flex-row-container\" sid=\""+samplers[i]+"\">\
|
||||
<div class=\"flex-row\">\
|
||||
<div>"+samplers_lookup_table[samplers[i]]+"</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>");
|
||||
}
|
||||
}
|
||||
|
||||
function highlightLoadLine(ref) {
|
||||
$("#loadlistcontent > div > div.popuplistselected").removeClass("popuplistselected");
|
||||
ref.addClass("popuplistselected");
|
||||
|
@ -1838,6 +1875,7 @@ $(document).ready(function(){
|
|||
button_format = $('#btn_format');
|
||||
button_softprompt = $("#btn_softprompt");
|
||||
button_userscripts= $("#btn_userscripts");
|
||||
button_samplers = $("#btn_samplers");
|
||||
button_mode = $('#btnmode')
|
||||
button_mode_label = $('#btnmode_label')
|
||||
button_send = $('#btnsend');
|
||||
|
@ -1886,6 +1924,10 @@ $(document).ready(function(){
|
|||
usloaded = $("#uslistloaded");
|
||||
us_accept = $("#btn_usaccept");
|
||||
us_close = $("#btn_usclose");
|
||||
samplerspopup = $("#samplerscontainer");
|
||||
samplerslist = $("#samplerslist");
|
||||
samplers_accept = $("#btn_samplersaccept");
|
||||
samplers_close = $("#btn_samplersclose");
|
||||
nspopup = $("#newgamecontainer");
|
||||
ns_accept = $("#btn_nsaccept");
|
||||
ns_close = $("#btn_nsclose");
|
||||
|
@ -1908,7 +1950,7 @@ $(document).ready(function(){
|
|||
modelname = msg.modelname;
|
||||
}
|
||||
refreshTitle();
|
||||
connect_status.html("<b>Connected to KoboldAI Process!</b>");
|
||||
connect_status.html("<b>Connected to KoboldAI!</b>");
|
||||
connect_status.removeClass("color_orange");
|
||||
connect_status.addClass("color_green");
|
||||
// Reset Menus
|
||||
|
@ -2310,6 +2352,8 @@ $(document).ready(function(){
|
|||
buildSPList(msg.data);
|
||||
} else if(msg.cmd == "buildus") {
|
||||
buildUSList(msg.data.unloaded, msg.data.loaded);
|
||||
} else if(msg.cmd == "buildsamplers") {
|
||||
buildSamplerList(msg.data);
|
||||
} else if(msg.cmd == "askforoverwrite") {
|
||||
// Show overwrite warning
|
||||
show([$(".saveasoverwrite")]);
|
||||
|
@ -2436,6 +2480,20 @@ $(document).ready(function(){
|
|||
}, 10);
|
||||
}
|
||||
|
||||
var samplers_click_handler = function(ev) {
|
||||
setTimeout(function() {
|
||||
if (samplers_dragging) {
|
||||
return;
|
||||
}
|
||||
var target = $(ev.target).closest(".samplerslistitem");
|
||||
var next = target.parent().next().find(".samplerslistitem");
|
||||
if (!next.length) {
|
||||
return;
|
||||
}
|
||||
next.parent().after(target.parent());
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Make the userscripts menu sortable
|
||||
var us_sortable_settings = {
|
||||
placeholder: "ussortable-placeholder",
|
||||
|
@ -2456,6 +2514,22 @@ $(document).ready(function(){
|
|||
connectWith: "#uslistunloaded",
|
||||
}, us_sortable_settings)).on("click", ".uslistitem", us_click_handler);
|
||||
|
||||
// Make the samplers menu sortable
|
||||
var samplers_sortable_settings = {
|
||||
placeholder: "samplerssortable-placeholder",
|
||||
start: function() { samplers_dragging = true; },
|
||||
stop: function() { samplers_dragging = false; },
|
||||
delay: 2,
|
||||
cursor: "move",
|
||||
tolerance: "pointer",
|
||||
opacity: 0.21,
|
||||
revert: 173,
|
||||
scrollSensitivity: 64,
|
||||
scrollSpeed: 10,
|
||||
}
|
||||
samplerslist.sortable($.extend({
|
||||
}, samplers_sortable_settings)).on("click", ".samplerslistitem", samplers_click_handler);
|
||||
|
||||
// Bind actions to UI buttons
|
||||
button_send.on("click", function(ev) {
|
||||
dosubmit();
|
||||
|
@ -2590,6 +2664,10 @@ $(document).ready(function(){
|
|||
button_userscripts.on("click", function(ev) {
|
||||
socket.send({'cmd': 'uslistrequest', 'data': ''});
|
||||
});
|
||||
|
||||
button_samplers.on("click", function(ev) {
|
||||
socket.send({'cmd': 'samplerlistrequest', 'data': ''});
|
||||
});
|
||||
|
||||
load_close.on("click", function(ev) {
|
||||
hideLoadPopup();
|
||||
|
@ -2623,6 +2701,16 @@ $(document).ready(function(){
|
|||
socket.send({'cmd': 'usload', 'data': ''});
|
||||
hideUSPopup();
|
||||
});
|
||||
|
||||
samplers_close.on("click", function(ev) {
|
||||
hideSamplersPopup();
|
||||
});
|
||||
|
||||
samplers_accept.on("click", function(ev) {
|
||||
hideMessage();
|
||||
socket.send({'cmd': 'samplers', 'data': samplerslist.find(".samplerslistitem").map(function() { return parseInt($(this).attr("sid")); }).toArray()});
|
||||
hideSamplersPopup();
|
||||
});
|
||||
|
||||
button_newgame.on("click", function(ev) {
|
||||
if(connected) {
|
||||
|
|
|
@ -457,6 +457,26 @@ body.connected #popupfooter, #popupfooter.always-available {
|
|||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#samplerspopup {
|
||||
width: 300px;
|
||||
background-color: #262626;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
#samplerspopup {
|
||||
width: 100%;
|
||||
background-color: #262626;
|
||||
margin-top: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
#samplerslist {
|
||||
height: 300px;
|
||||
overflow-y: scroll;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#nspopup {
|
||||
width: 350px;
|
||||
background-color: #262626;
|
||||
|
@ -750,7 +770,7 @@ body.connected .dropdown-item:hover, .dropdown-item.always-available:hover {
|
|||
background-color: #3bf723;
|
||||
}
|
||||
|
||||
.ussortable-placeholder {
|
||||
.ussortable-placeholder, .samplerssortable-placeholder {
|
||||
height: 4px;
|
||||
background-color: #3bf723;
|
||||
}
|
||||
|
@ -1340,7 +1360,7 @@ body.connected .popupfooter, .popupfooter.always-available {
|
|||
background-color: #688f1f;
|
||||
}
|
||||
|
||||
.uslistitem {
|
||||
.uslistitem, .samplerslistitem {
|
||||
padding: 12px 10px 12px 10px;
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
|
@ -1352,11 +1372,11 @@ body.connected .popupfooter, .popupfooter.always-available {
|
|||
transition: background-color 0.25s ease-in;
|
||||
}
|
||||
|
||||
.uslistitemsub {
|
||||
.uslistitemsub, .samplerslistitemsub {
|
||||
color: #ba9;
|
||||
}
|
||||
|
||||
.uslistitem:hover {
|
||||
.uslistitem:hover, .samplerslistitem:hover {
|
||||
cursor: move;
|
||||
background-color: #688f1f;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<link rel="stylesheet" href="static/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="static/bootstrap-toggle.min.css">
|
||||
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
|
||||
<link rel="stylesheet" href="static/custom.css?ver=1.18b">
|
||||
<link rel="stylesheet" href="static/custom.css?ver=1.18c">
|
||||
|
||||
<script src="static/jquery-3.6.0.min.js"></script>
|
||||
<script src="static/jquery-ui.sortable.min.js"></script>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<script src="static/bootstrap.min.js"></script>
|
||||
<script src="static/bootstrap-toggle.min.js"></script>
|
||||
<script src="static/rangy-core.min.js"></script>
|
||||
<script src="static/application.js?ver=1.18d"></script>
|
||||
<script src="static/application.js?ver=1.18e"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="file" id="remote-save-select" accept="application/json" style="display:none">
|
||||
|
@ -71,6 +71,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="#" id="btn_format">Formatting</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#" id="btn_samplers">Samplers</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#" id="btn_userscripts">Userscripts</a>
|
||||
</li>
|
||||
|
@ -299,6 +302,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popupcontainer hidden" id="samplerscontainer">
|
||||
<div id="samplerspopup">
|
||||
<div class="popuptitlebar">
|
||||
<div class="popuptitletext">Drag-and-drop to change the order in which the samplers are applied</div>
|
||||
</div>
|
||||
<div id="samplerslist">
|
||||
</div>
|
||||
<div class="popupfooter">
|
||||
<button type="button" class="btn btn-primary" id="btn_samplersaccept">Save</button>
|
||||
<button type="button" class="btn btn-primary" id="btn_samplersclose">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popupcontainer hidden" id="loadcontainerdelete">
|
||||
<div id="loadpopupdelete">
|
||||
<div class="popuptitlebar">
|
||||
|
|
Loading…
Reference in New Issue