This commit is contained in:
GuiAworld
2022-08-16 22:45:40 -03:00
parent 4c67f62a10
commit a16c129950
6 changed files with 57 additions and 92 deletions

View File

@@ -6285,7 +6285,12 @@ def UI_2_var_change(data):
#Now let's save except for story changes
if classname != "story_settings":
with open("settings/{}.v2_settings".format(classname), "w") as settings_file:
if classname == "model_settings":
filename = "settings/{}.v2_settings".format(koboldai_vars.model.replace("/", "_"))
else:
filename = "settings/{}.v2_settings".format(classname)
with open(filename, "w") as settings_file:
settings_file.write(getattr(koboldai_vars, "_{}".format(classname)).to_json())
return {'id': data['ID'], 'status': "Saved"}
@@ -6295,7 +6300,7 @@ def UI_2_var_change(data):
#==================================================================#
@socketio.on('save_story')
def UI_2_save_story(data):
print("Saving Story")
if data is None:
#We need to check to see if there is a file already and if it's not the same story so we can ask the client if this is OK
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
@@ -6599,11 +6604,14 @@ def UI_2_phrase_bias_update(biases):
# Event triggered to rely a message
#==================================================================#
def socket_io_relay(queue, socketio):
print("started relay")
while True:
if not queue.empty():
print("got relay message")
data = queue.get()
#socketio.emit(data[0], data[1], **data[2])
socketio.emit(data[0], data[1], broadcast=True, room="UI_2")
print("sent")
time.sleep(0)

View File

@@ -298,7 +298,7 @@ class settings(object):
pickle.dump(data, output)
output.seek(0)
return "base64:{}".format(base64.encodebytes(output.read()).decode())
return json.dumps(json_data, default=to_base64)
return json.dumps(json_data, default=to_base64, indent="\t")
def from_json(self, data):
if isinstance(data, str):
@@ -337,7 +337,8 @@ class settings(object):
class model_settings(settings):
local_only_variables = ['badwordsids', 'apikey', 'tqdm', 'socketio', 'default_preset']
no_save_variables = ['tqdm', 'socketio']
no_save_variables = ['tqdm', 'tqdm_progress', 'tqdm_rem_time', 'socketio', 'modelconfig', 'custmodpth', 'generated_tkns',
'loaded_layers', 'total_layers', 'total_download_chunks', 'downloaded_chunks']
settings_name = "model"
def __init__(self, socketio):
self.socketio = socketio
@@ -600,8 +601,8 @@ class story_settings(settings):
self.actionmode = 0
class user_settings(settings):
local_only_variables = ['socketio']
no_save_variables = ['socketio']
local_only_variables = ['socketio', 'importjs']
no_save_variables = ['socketio', 'importnum', 'importjs', 'loadselect', 'spselect', 'svowname', 'saveow', 'laststory', 'sid']
settings_name = "user"
def __init__(self, socketio):
self.socketio = socketio

View File

@@ -331,7 +331,7 @@ input[type="range"]::-ms-fill-upper {
grid-template-columns: 135px 42px;
row-gap: 0.2em;
background-color: var(--setting_background);
color: var(--text);
color: var(--setting_text);
border-radius: var(--radius_settings_background);
padding: 3px;
margin: 2px;
@@ -376,6 +376,7 @@ input[type="range"]::-ms-fill-upper {
}
.setting_label {
display: flex;
grid-area: label;
overflow: hidden;
padding: 5px;
@@ -407,46 +408,12 @@ input[type="range"]::-ms-fill-upper {
}
/*-----------------------------------------------*/
.helpicon {
display: inline-block;
font-family: sans-serif;
font-weight: bold;
text-align: center;
width: 2ex;
height: 2ex;
font-size: 1.8ex;
line-height: 1.8ex;
border-radius: 1.2ex;
margin-right: 4px;
padding: 1px;
color: var(--help_icon_text);
background: var(--help_icon);
border: 1px solid var(--help_icon_text);
text-decoration: none;
color: var(--setting_text);
cursor: help;
}
.helpicon .helptext {
display: none;
font-family: sans-serif;
position: absolute;
z-index: 100;
text-shadow: none !important;
}
.helpicon:hover .helptext {
display: inline-block;
position: fixed;
width: 250px;
background-color: var(--tooltip_background);
color: var(--tooltip_text);
font-size: 11pt;
z-index: 100;
font-weight: normal;
line-height: normal;
border-radius: 6px;
padding: 5px;
margin-left:10px;
border: 1px solid var(--tooltip_text);
font-size: 14px !important;
flex: auto;
width: 15px;
align-self: flex-end;
}
/*----------------LEFT FLYOUT MENU------------------*/
@@ -1643,3 +1610,7 @@ body.NotConnected {
/* Support for IE. */
font-feature-settings: 'liga';
}
h2 .material-icons-outlined {
font-size: 32px;
}

View File

@@ -1247,10 +1247,10 @@ function world_info_folder(data) {
title.addEventListener('drop', drop);
collapse_icon = document.createElement("span");
collapse_icon.id = "world_info_folder_collapse_"+folder_name;
collapse_icon.classList.add("oi");
collapse_icon.classList.add("wi_folder_collapser");
collapse_icon.setAttribute("data-glyph", "chevron-bottom");
collapse_icon.classList.add("material-icons-outlined");
collapse_icon.setAttribute("folder", folder_name);
collapse_icon.textContent = "expand_more";
collapse_icon.onclick = function () {
hide_wi_folder(this.getAttribute("folder"));
document.getElementById('world_info_folder_expand_'+this.getAttribute("folder")).classList.remove('hidden');
@@ -1259,10 +1259,10 @@ function world_info_folder(data) {
title.append(collapse_icon);
expand_icon = document.createElement("span");
expand_icon.id = "world_info_folder_expand_"+folder_name;
expand_icon.classList.add("oi");
expand_icon.classList.add("wi_folder_collapser");
expand_icon.setAttribute("data-glyph", "chevron-right");
expand_icon.classList.add("material-icons-outlined");
expand_icon.setAttribute("folder", folder_name);
expand_icon.textContent = "chevron_right";
expand_icon.onclick = function () {
unhide_wi_folder(this.getAttribute("folder"));
document.getElementById('world_info_folder_collapse_'+this.getAttribute("folder")).classList.remove('hidden');
@@ -1271,8 +1271,9 @@ function world_info_folder(data) {
expand_icon.classList.add("hidden");
title.append(expand_icon);
icon = document.createElement("span");
icon.classList.add("oi");
icon.setAttribute("data-glyph", "folder");
icon.classList.add("material-icons-outlined");
icon.setAttribute("folder", folder_name);
icon.textContent = "folder";
title.append(icon);
title_text = document.createElement("span");
title_text.setAttribute("contenteditable", true);
@@ -1287,16 +1288,20 @@ function world_info_folder(data) {
title.append(title_text);
folder.append(title);
//create add button
new_icon = document.createElement("span");
new_icon.classList.add("wi_add_button");
add_icon = document.createElement("span");
add_icon.classList.add("oi");
add_icon.classList.add("wi_add_button");
add_icon.setAttribute("data-glyph", "plus");
add_icon.textContent = "Add World Info Entry";
add_icon.setAttribute("folder", folder_name);
add_icon.onclick = function() {
add_icon.classList.add("material-icons-outlined");
add_icon.textContent = "post_add";
new_icon.append(add_icon);
add_text = document.createElement("span");
add_text.textContent = "Add World Info Entry";
add_text.setAttribute("folder", folder_name);
add_text.onclick = function() {
create_new_wi_entry(this.getAttribute("folder"));
}
folder.append(add_icon);
new_icon.append(add_text);
folder.append(new_icon);
//We want to insert this folder before the next folder
if (i+1 < folders.length) {
@@ -1350,12 +1355,16 @@ function world_info_folder(data) {
add_folder.id = "new_world_info_button";
temp = document.createElement("h2");
add_icon = document.createElement("span");
add_icon.classList.add("oi");
add_icon.setAttribute("data-glyph", "plus");
add_icon.textContent = "Add World Info Folder";
icon = document.createElement("span");
icon.classList.add("material-icons-outlined");
icon.textContent = "create_new_folder";
add_icon.append(icon);
text_span = document.createElement("span");
text_span.textContent = "Add World Info Folder";
add_icon.onclick = function() {
socket.emit("create_world_info_folder", {});
}
add_icon.append(text_span);
temp.append(add_icon);
add_folder.append(temp);
document.getElementById("WI_Area").append(add_folder);

View File

@@ -63,7 +63,7 @@
<div class="story_title_icons">
<span class="material-icons-outlined cursor" title="New Story" onclick="socket.emit('new_story', '');">description</span>
<span class="material-icons-outlined cursor" title="Load Story" onclick="socket.emit('load_story_list', '');">folder_open</span>
<span class="material-icons-outlined cursor var_sync_alt_story_gamesaved" title="Save Story">save</span>
<span class="material-icons-outlined cursor var_sync_alt_story_gamesaved" title="Save Story" onclick='socket.emit("save_story", null, (response) => {save_as_story(response);});'>save</span>
<span class="material-icons-outlined cursor" title="Import Story" onclick="document.getElementById('import_aidg_club_popup').classList.remove('hidden');">cloud_download</span>
<span class="material-icons-outlined cursor" title="Download Story" onclick="document.getElementById('download_iframe').src = 'json';">file_download</span>
</div>
@@ -99,18 +99,12 @@
<div class="setting_container_single">
<!---Top Row---->
<span class="setting_label">
Sample Order:
<span class="helpicon">
?
<span class="helptext">
Sample Order Tooltip
</span>
</span>
<span>Sample Order:&nbsp;</span><span class="helpicon material-icons-outlined" title="Help Text Here">help_icon</span>
</span>
<!---Bottom Row---->
<span class="setting_item">
<div style="display:flex;flex-direction:row;">
<ul id="sample_order_list" style="width:calc(var(--flyout_menu_width) - 60px);">
<ul id="sample_order_list" style="width:calc(var(--flyout_menu_width) - 60px);list-style-position: inside; padding: 0;">
<li class="sample_order cursor" onclick="select_sample(this);">Top-k Sampling</li>
<li class="sample_order cursor" onclick="select_sample(this);">Top-a Sampling</li>
<li class="sample_order cursor" onclick="select_sample(this);">Top-p Sampling</li>
@@ -203,13 +197,7 @@
{% endwith %}
<div class="setting_container">
<span class="setting_label">
Maximize Game Text Space:
<span class="helpicon">
?
<span class="helptext">
When enabled and both menus are un-pinned, the game screen will take up all avaialable space. When disabled, the game screen will be centered.
</span>
</span>
<span>Maximize Game Text Space: &nbsp;</span><span class="helpicon material-icons-outlined" title="When enabled and both menus are un-pinned, the game screen will take up all avaialable space. When disabled, the game screen will be centered.">help_icon</span>
</span>
<span class="setting_item">
<input type=checkbox id="preserve_game_space_setting" data-size=mini data-onstyle=success data-toggle=toggle onchange="preserve_game_space(this.checked)"/>
@@ -220,13 +208,7 @@
</div>
<div class="setting_container">
<span class="setting_label">
Keep options on Right:
<span class="helpicon">
?
<span class="helptext">
When enabled and only the story menu is pinned, the generated story options will be shown on the right instead of the left of the game text.
</span>
</span>
<span>Keep options on Right:&nbsp;</span><span class="helpicon material-icons-outlined" title="When enabled and only the story menu is pinned, the generated story options will be shown on the right instead of the left of the game text.">help_icon</span>
</span>
<span class="setting_item">
<input type=checkbox id="options_on_right" data-size=mini data-onstyle=success data-toggle=toggle onchange="options_on_right(this.checked)"/>

View File

@@ -3,13 +3,7 @@
<div class="setting_container">
<!---Top Row---->
<span class="setting_label">
{{ item['label'] }}:
<span class="helpicon">
?
<span class="helptext">
{{ item['tooltip'] }}
</span>
</span>
<span>{{ item['label'] }}:&nbsp;</span><span class="helpicon material-icons-outlined" title="{{ item['tooltip'] }}">help_icon</span>
</span>
{% if (item['unit'] != 'bool') and (item['unit'] != 'text') %}
<input autocomplete="off" class="setting_value var_sync_{{ item['classname'] }}_{{ item['name'] }}" id="{{ item['classname'] }}_{{ item['name'] }}_cur"