mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge branch 'UI2' into ui2-shortcuts
This commit is contained in:
11
aiserver.py
11
aiserver.py
@@ -277,10 +277,10 @@ model_menu = {
|
||||
|
||||
class Send_to_socketio(object):
|
||||
def write(self, bar):
|
||||
bar = bar.replace("\r", "").replace("\n", "")
|
||||
if bar != "":
|
||||
logger.info(bar)
|
||||
#print('\r' + bar, end='')
|
||||
bar = bar.replace("\r", "").replace("\n", "").replace(chr(0), "")
|
||||
if bar != "" and [ord(num) for num in bar] != [27, 91, 65]: #No idea why we're getting the 27, 1, 65 character set, just killing to so we can move on
|
||||
#logger.info(bar)
|
||||
print('\r' + bar, end='')
|
||||
time.sleep(0.01)
|
||||
try:
|
||||
emit('from_server', {'cmd': 'model_load_status', 'data': bar.replace(" ", " ")}, broadcast=True, room="UI_1")
|
||||
@@ -1788,9 +1788,8 @@ def patch_transformers_download():
|
||||
class Send_to_socketio(object):
|
||||
def write(self, bar):
|
||||
bar = bar.replace("\r", "").replace("\n", "")
|
||||
logger.debug(bar)
|
||||
|
||||
if bar != "":
|
||||
if bar != "" and [ord(num) for num in bar] != [27, 91, 65]: #No idea why we're getting the 27, 1, 65 character set, just killing to so we can move on
|
||||
try:
|
||||
print('\r' + bar, end='')
|
||||
emit('from_server', {'cmd': 'model_load_status', 'data': bar.replace(" ", " ")}, broadcast=True, room="UI_1")
|
||||
|
@@ -568,7 +568,8 @@ class settings(object):
|
||||
class model_settings(settings):
|
||||
local_only_variables = ['badwordsids', 'apikey', 'tqdm', 'socketio', 'default_preset', 'koboldai_vars']
|
||||
no_save_variables = ['tqdm', 'tqdm_progress', 'tqdm_rem_time', 'socketio', 'modelconfig', 'custmodpth', 'generated_tkns',
|
||||
'loaded_layers', 'total_layers', 'total_download_chunks', 'downloaded_chunks', 'presets', 'default_preset', 'koboldai_vars']
|
||||
'loaded_layers', 'total_layers', 'total_download_chunks', 'downloaded_chunks', 'presets', 'default_preset',
|
||||
'koboldai_vars', 'welcome', 'welcome_default']
|
||||
settings_name = "model"
|
||||
def __init__(self, socketio, koboldai_vars):
|
||||
self.socketio = socketio
|
||||
@@ -593,7 +594,7 @@ class model_settings(settings):
|
||||
self.oaiapikey = "" # API key to use for OpenAI API calls
|
||||
self.configname = None
|
||||
self.online_model = ''
|
||||
self.welcome_default = "<img src='static/Welcome_Logo.png' style='max-width: 720px; width: 100%;'><br/>Please load a model from the left." # Custom Welcome Text
|
||||
self.welcome_default = "<img id='welcome-logo' src='static/Welcome_Logo.png' draggable='False'><br/>Please load a model from the left." # Custom Welcome Text
|
||||
self.welcome = self.welcome_default
|
||||
self.koboldai_vars = koboldai_vars
|
||||
|
||||
@@ -690,7 +691,12 @@ class model_settings(settings):
|
||||
else:
|
||||
self.tqdm.update(value-old_value)
|
||||
if self.total_download_chunks is not None:
|
||||
self.tqdm_progress = 0 if self.total_download_chunks==0 else round(float(self.downloaded_chunks)/float(self.total_download_chunks)*100, 1)
|
||||
if self.total_download_chunks==0:
|
||||
self.tqdm_progress = 0
|
||||
elif float(self.downloaded_chunks) > float(self.total_download_chunks):
|
||||
self.tqdm_progress = 100
|
||||
else:
|
||||
self.tqdm_progress = round(float(self.downloaded_chunks)/float(self.total_download_chunks)*100, 1)
|
||||
else:
|
||||
self.tqdm_progress = 0
|
||||
if self.tqdm.format_dict['rate'] is not None:
|
||||
|
@@ -1141,28 +1141,26 @@ body {
|
||||
grid-template-areas: "menuicon gamescreen options lefticon"
|
||||
"menuicon theme theme lefticon"
|
||||
"menuicon inputrow inputrow lefticon";
|
||||
grid-template-columns: 30px auto var(--story_options_size) 30px;
|
||||
grid-template-columns: 30px auto fit-content(30%) 30px;
|
||||
grid-template-rows: auto min-content 100px;
|
||||
}
|
||||
.main-grid[option_length="0"][model_numseqs="1"] {
|
||||
grid-template-columns: 30px auto 0px 30px;
|
||||
}
|
||||
|
||||
.main-grid.settings_pinned {
|
||||
margin-left: var(--flyout_menu_width);
|
||||
*grid-template-columns: 30px auto var(--story_options_size) 30px;
|
||||
}
|
||||
|
||||
.main-grid.story_pinned {
|
||||
margin-right: var(--flyout_menu_width);
|
||||
/*margin-left: var(--setting_menu_closed_width_no_pins_width);
|
||||
grid-template-areas: var(--story_pinned_areas);
|
||||
grid-template-columns: var(--story_pinned_area_widths);*/
|
||||
}
|
||||
.main-grid.settings_pinned.story_pinned {
|
||||
margin-left: var(--flyout_menu_width);
|
||||
margin-right: var(--flyout_menu_width);
|
||||
grid-template-areas: "menuicon gamescreen options lefticon"
|
||||
"menuicon theme theme lefticon"
|
||||
"menuicon inputrow inputrow lefticon";
|
||||
grid-template-columns: 30px auto var(--story_options_size) 30px;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@media only screen and (max-aspect-ratio: 7/5) {
|
||||
@@ -2365,6 +2363,13 @@ body {
|
||||
color: white
|
||||
}
|
||||
|
||||
#welcome-logo {
|
||||
pointer-events: none;
|
||||
max-width: 720px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Popups */
|
||||
#popup-container {
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
|
@@ -223,6 +223,7 @@ function fix_text(val) {
|
||||
|
||||
function create_options(action) {
|
||||
//Set all options before the next chunk to hidden
|
||||
document.getElementById('main-grid').setAttribute('option_length', action.action.Options.length);
|
||||
var option_container = document.getElementById("Select Options");
|
||||
var current_chunk = parseInt(document.getElementById("action_count").textContent)+1;
|
||||
if (current_chunk != action.id.toString()) {
|
||||
@@ -769,17 +770,17 @@ function var_changed(data) {
|
||||
}
|
||||
|
||||
//if we changed the gen amount, make sure our option area is set/not set
|
||||
if ((data.classname == 'model') && (data.name == 'numseqs')) {
|
||||
if (data.value == 1) {
|
||||
//allow our options to collapse to 0%, but no more than 30% (in case there is a redo or the like)
|
||||
var r = document.querySelector(':root');
|
||||
r.style.setProperty('--story_options_size', 'fit-content(30%)');
|
||||
} else {
|
||||
//static 30%
|
||||
var r = document.querySelector(':root');
|
||||
r.style.setProperty('--story_options_size', '30%');
|
||||
}
|
||||
}
|
||||
//if ((data.classname == 'model') && (data.name == 'numseqs')) {
|
||||
// if (data.value == 1) {
|
||||
// //allow our options to collapse to 0%, but no more than 30% (in case there is a redo or the like)
|
||||
// var r = document.querySelector(':root');
|
||||
// r.style.setProperty('--story_options_size', 'fit-content(30%)');
|
||||
// } else {
|
||||
// //static 30%
|
||||
// var r = document.querySelector(':root');
|
||||
// r.style.setProperty('--story_options_size', 'fit-content(30%)');
|
||||
// }
|
||||
//}
|
||||
|
||||
//if we're updating generated tokens, let's show that in our status bar
|
||||
if ((data.classname == 'model') && (data.name == 'tqdm_progress')) {
|
||||
@@ -1700,7 +1701,7 @@ function world_info_entry(data) {
|
||||
var original_focus = null;
|
||||
if (document.getElementById("world_info_"+data.uid)) {
|
||||
//First let's get the id of the element we're on so we can restore it after removing the object
|
||||
//original_focus = document.activeElement.id;
|
||||
original_focus = document.activeElement.id;
|
||||
//console.log("Active ID: "+original_focus);
|
||||
//console.log(document.activeElement);
|
||||
//document.getElementById("world_info_"+data.uid).remove();
|
||||
@@ -1829,7 +1830,7 @@ function world_info_entry(data) {
|
||||
if (attribute != '') {
|
||||
i += 1;
|
||||
attribute_area = document.createElement("div");
|
||||
label = document.createElement("span");
|
||||
let label = document.createElement("span");
|
||||
label.textContent = "\xa0\xa0\xa0\xa0Attribute: ";
|
||||
attribute_area.append(label);
|
||||
input = document.createElement("input");
|
||||
@@ -1843,7 +1844,7 @@ function world_info_entry(data) {
|
||||
input.setAttribute("uid", data.uid);
|
||||
input.setAttribute("data_type", "attribute");
|
||||
input.id = "wpp_"+data.uid+"_attr_"+i
|
||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||
input.onchange = function() {do_wpp(this.parentElement.parentElement.parentElement)};
|
||||
attribute_area.append(input);
|
||||
wpp_attributes_area.append(attribute_area);
|
||||
j=-1;
|
||||
@@ -1857,7 +1858,7 @@ function world_info_entry(data) {
|
||||
input.type = "text";
|
||||
input.setAttribute("contenteditable", true);
|
||||
input.ondragstart=function() {event.preventDefault();event.stopPropagation();};
|
||||
input.onchange = function() {do_wpp(this.parentElement.parentElement)};
|
||||
input.onchange = function() {do_wpp(this.parentElement.parentElement.parentElement)};
|
||||
input.onfocus=function() {this.parentElement.parentElement.parentElement.setAttribute('draggable', 'false');this.setAttribute('draggable', 'false');};
|
||||
input.onblur=function() {this.parentElement.parentElement.parentElement.setAttribute('draggable', 'true');this.setAttribute('draggable', 'true');};
|
||||
input.ondragstart=function() {event.preventDefault();event.stopPropagation();};
|
||||
@@ -1883,7 +1884,7 @@ function world_info_entry(data) {
|
||||
input.setAttribute("data_type", "value");
|
||||
input.id = "wpp_"+data.uid+"_value_"+i+"_blank";
|
||||
last_new_value = input;
|
||||
input.onchange = function() {if (this.value != "") {on_new_wi_item = this.id;do_wpp(this.parentElement.parentElement)}};
|
||||
input.onchange = function() {if (this.value != "") {on_new_wi_item = this.id;do_wpp(this.parentElement.parentElement.parentElement)}};
|
||||
value_area.append(input);
|
||||
wpp_attributes_area.append(value_area);
|
||||
}
|
||||
@@ -1904,7 +1905,7 @@ function world_info_entry(data) {
|
||||
input.setAttribute("value_num", i);
|
||||
input.setAttribute("data_type", "attribute");
|
||||
input.id = "wpp_"+data.uid+"_attr_blank";
|
||||
input.onchange = function() {if (this.value != "") {on_new_wi_item=this.id;do_wpp(this.parentElement.parentElement)}};
|
||||
input.onchange = function() {if (this.value != "") {on_new_wi_item=this.id;do_wpp(this.parentElement.parentElement.parentElement)}};
|
||||
attribute_area.append(input);
|
||||
wpp_attributes_area.append(attribute_area);
|
||||
|
||||
|
@@ -41,11 +41,11 @@
|
||||
</div>
|
||||
|
||||
<!------------ Main Screen--------------------->
|
||||
<div id="main-grid" class="main-grid settings_pinned" onclick="close_menus();">
|
||||
<div id="main-grid" class="main-grid settings_pinned var_sync_alt_model_numseqs" onclick="close_menus();" option_length="0">
|
||||
<!------------ Game Text Screen--------------------->
|
||||
<div class="gamescreen" id="gamescreen">
|
||||
<div id="disconnect_message"><center><h1>Disconnected</h1></center></div>
|
||||
<div id="welcome_text" class="var_sync_model_welcome"></div>
|
||||
<div id="welcome_text" class="var_sync_model_welcome" draggable="False"></div>
|
||||
<div class="gametext" id="Selected Text" contenteditable=false onblur="select_game_text(null);" onclick="select_game_text(null);" onkeyup="select_game_text(event);">
|
||||
<span id="story_prompt" class="var_sync_story_prompt var_sync_alt_story_prompt_in_ai rawtext hidden" chunk="-1"></span>
|
||||
</div>
|
||||
|
@@ -1 +1 @@
|
||||
div#welcome_text.var_sync_model_welcome { opacity: 0; pointer-events: none }
|
||||
#welcome_text { display:none; pointer-events: none }
|
||||
|
2
utils.py
2
utils.py
@@ -183,7 +183,7 @@ def _download_with_aria2(aria2_config: str, total_length: int, directory: str =
|
||||
def write(self, bar):
|
||||
bar = bar.replace("\r", "").replace("\n", "")
|
||||
|
||||
if bar != "":
|
||||
if bar != "" and [ord(num) for num in bar] != [27, 91, 65]: #No idea why we're getting the 27, 1, 65 character set, just killing to so we can move on
|
||||
try:
|
||||
print('\r' + bar, end='')
|
||||
try:
|
||||
|
Reference in New Issue
Block a user