diff --git a/aiserver.py b/aiserver.py index 80eec7c7..b9334ff1 100644 --- a/aiserver.py +++ b/aiserver.py @@ -7238,19 +7238,23 @@ def UI_2_Rename_World_Info_Folder(data): #==================================================================# @socketio.on('edit_world_info') def UI_2_edit_world_info(data): - print("Rename_World_Info_Folder") + print("edit_world_info") print(data) + if 'wpp' not in data: + wpp = {'name': "", 'type': "", 'attributes': {}} + else: + wpp = data['wpp'] if data['uid'] == -1: koboldai_vars.worldinfo_v2.add_item(data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['content'], - data['comment']) + data['comment'], wpp=wpp) emit("delete_new_world_info_entry", {}) else: koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['content'], - data['comment']) + data['comment'], wpp=wpp) #==================================================================# diff --git a/gensettings.py b/gensettings.py index 237e97e2..fad930b5 100644 --- a/gensettings.py +++ b/gensettings.py @@ -99,7 +99,7 @@ gensettingstf = [ "max": 1.0, "step": 0.01, "default": 0.0, - "tooltip": "Alternative sampling method that reduces the randomness of the AI whenever the probability of one token is much higher than all the others. Higher values have a stronger effect. (Put this value on 1 to disable its effect)", + "tooltip": "Alternative sampling method that reduces the randomness of the AI whenever the probability of one token is much higher than all the others. Higher values have a stronger effect. (Put this value on 0 to disable its effect)", "menu_path": "Settings", "sub_path": "Sampling", "classname": "model", @@ -189,7 +189,7 @@ gensettingstf = [ "max": 5, "step": 1, "default": 3, - "tooltip": "Number of historic actions to scan for W Info keys.", + "tooltip": "Number of historic actions to scan for World Info keys.", "menu_path": "World Info", "sub_path": "", "classname": "user", @@ -264,7 +264,7 @@ gensettingstf = [ "max": 1, "step": 1, "default": 0, - "tooltip": "Scan the AI's output for world info keys as it's generating the output.", + "tooltip": "Scan the AI's output for World Info keys as it's generating the output.", "menu_path": "World Info", "sub_path": "", "classname": "story", @@ -565,7 +565,7 @@ gensettingsik =[{ "max": 5, "step": 1, "default": 3, - "tooltip": "Number of historic actions to scan for W Info keys.", + "tooltip": "Number of historic actions to scan for World Info keys.", "menu_path": "User", "classname": "user", "name": "widepth" diff --git a/koboldai_settings.py b/koboldai_settings.py index c644c25c..a94562f8 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1166,7 +1166,7 @@ class KoboldWorldInfo(object): self.sync_world_info_to_old_format() self.socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2") - def add_item(self, title, key, keysecondary, folder, constant, content, comment): + def add_item(self, title, key, keysecondary, folder, constant, content, comment, wpp={'name': "", 'type': "", 'attributes': {}}): if len(self.world_info) == 0: uid = 0 else: @@ -1198,7 +1198,8 @@ class KoboldWorldInfo(object): "comment": comment, "token_length": token_length, "selective": len(keysecondary) > 0, - "used_in_game": constant + "used_in_game": constant, + 'wpp': wpp } except: print("Error:") @@ -1215,7 +1216,7 @@ class KoboldWorldInfo(object): self.socketio.emit("world_info_entry", self.world_info[uid], broadcast=True, room="UI_2") ignore = self.koboldai_vars.calc_ai_text() - def edit_item(self, uid, title, key, keysecondary, folder, constant, content, comment, before=None): + def edit_item(self, uid, title, key, keysecondary, folder, constant, content, comment, before=None, wpp={'name': "", 'type': "", 'attributes': {}}): old_folder = self.world_info[uid]['folder'] #move the world info entry if the folder changed or if there is a new order requested if old_folder != folder or before is not None: @@ -1236,7 +1237,9 @@ class KoboldWorldInfo(object): "content": content, "comment": comment, "token_length": token_length, - "selective": len(keysecondary) > 0 + "selective": len(keysecondary) > 0, + "used_in_game": constant, + 'wpp': wpp } self.story_settings.gamesaved = False diff --git a/static/koboldai.css b/static/koboldai.css index eefa1ca7..0d34a1a2 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -680,16 +680,7 @@ td.server_vars { margin-top: 10px; } -#story_menu_notes{ - margin: 10px 10px 0 10px; -} - -#story_menu_memory{ - margin: 10px 10px 0 10px; -} - - -#story_menu_author{ +.story_category_area{ margin: 10px 10px 0 10px; } diff --git a/static/koboldai.js b/static/koboldai.js index d3e0c4cc..c1ebdfbc 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1264,7 +1264,7 @@ function world_info_entry(data) { wpp_toggle.id = "world_info_wpp_toggle_"+data.uid; wpp_toggle.setAttribute("type", "checkbox"); wpp_toggle.setAttribute("uid", data.uid); - wpp_toggle.checked = ((data.wpp != "") && (data.wpp != undefined)); + wpp_toggle.checked = ((data.wpp.type != "")); wpp_toggle.setAttribute("data-size", "mini"); wpp_toggle.setAttribute("data-onstyle", "success"); wpp_toggle.setAttribute("data-toggle", "toggle"); @@ -1283,54 +1283,62 @@ function world_info_entry(data) { //w++ data world_info_wpp_area = world_info_card.querySelector('#world_info_wpp_area_'); world_info_wpp_area.id = "world_info_wpp_area_"+data.uid; + world_info_wpp_area.setAttribute("uid", data.uid); wpp_type = world_info_card.querySelector('#wpp_type_'); wpp_type.id = "wpp_type_"+data.uid; wpp_type.setAttribute("uid", data.uid); + wpp_type.setAttribute("data_type", "type"); if ("wpp" in data) { wpp_type.value = data.wpp.type; } wpp_name = world_info_card.querySelector('#wpp_name_'); wpp_name.id = "wpp_name_"+data.uid; wpp_name.setAttribute("uid", data.uid); + wpp_name.setAttribute("data_type", "name"); if ("wpp" in data) { wpp_name.value = data.wpp.name; } - if (data.wpp != null) { - for (attribute of data.wpp.attributes) { - attribute_area = document.createElement("div"); - label = document.createElement("span"); - label.textContent = "Attribute: "; - attribute_area.append(label); - input = document.createElement("input"); - input.value = attribute.attribute; - input.setAttribute("uid", data.uid); - input.setAttribute("attribute", attribute.attribute); - input.onchange = function() {do_wpp(this.parentElement.parentElement)}; - attribute_area.append(input); - world_info_wpp_area.append(attribute_area); - for (value of attribute.values) { + if ('attributes' in data.wpp) { + for (const [attribute, value] of Object.entries(data.wpp.attributes)) { + if (attribute != '') { + attribute_area = document.createElement("div"); + label = document.createElement("span"); + label.textContent = "Attribute: "; + attribute_area.append(label); + input = document.createElement("input"); + input.value = attribute; + input.type = "text"; + input.setAttribute("uid", data.uid); + input.setAttribute("data_type", "attribute"); + input.onchange = function() {do_wpp(this.parentElement.parentElement)}; + attribute_area.append(input); + world_info_wpp_area.append(attribute_area); + for (value of value) { + value_area = document.createElement("div"); + label = document.createElement("span"); + label.textContent = " Value: "; + value_area.append(label); + input = document.createElement("input"); + input.type = "text"; + input.onchange = function() {do_wpp(this.parentElement.parentElement)}; + input.value = value; + input.setAttribute("uid", data.uid); + input.setAttribute("data_type", "value"); + value_area.append(input); + world_info_wpp_area.append(value_area); + } value_area = document.createElement("div"); label = document.createElement("span"); label.textContent = " Value: "; value_area.append(label); input = document.createElement("input"); - input.onchange = function() {do_wpp(this.parentElement.parentElement)}; - input.value = value; + input.type = "text"; input.setAttribute("uid", data.uid); - input.setAttribute("attribute", attribute.attribute); + input.setAttribute("data_type", "value"); + input.onchange = function() {do_wpp(this.parentElement.parentElement)}; value_area.append(input); world_info_wpp_area.append(value_area); } - value_area = document.createElement("div"); - label = document.createElement("span"); - label.textContent = " Value: "; - value_area.append(label); - input = document.createElement("input"); - input.setAttribute("uid", data.uid); - input.setAttribute("attribute", attribute.attribute); - input.onchange = function() {do_wpp(this.parentElement.parentElement)}; - value_area.append(input); - world_info_wpp_area.append(value_area); } } attribute_area = document.createElement("div"); @@ -1339,8 +1347,9 @@ function world_info_entry(data) { attribute_area.append(label); input = document.createElement("input"); input.value = ""; + input.type = "text"; input.setAttribute("uid", data.uid); - input.setAttribute("attribute", ""); + input.setAttribute("data_type", "attribute"); input.onchange = function() {do_wpp(this.parentElement.parentElement)}; attribute_area.append(input); world_info_wpp_area.append(attribute_area); @@ -1421,6 +1430,16 @@ function world_info_entry(data) { $('#world_info_constant_'+data.uid).bootstrapToggle(); $('#world_info_wpp_toggle_'+data.uid).bootstrapToggle(); + + //hide/unhide w++ + if (data.wpp.type != "") { + world_info_wpp_area.classList.remove("hidden"); + content_area.classList.add("hidden"); + } else { + world_info_wpp_area.classList.add("hidden"); + content_area.classList.remove("hidden"); + } + assign_world_info_to_action(null, data.uid); update_token_lengths(); @@ -1576,7 +1595,28 @@ function show_error_message(data) { } function do_wpp(wpp_area) { - console.log(wpp_area); + wpp = {}; + wpp['attributes'] = {}; + uid = wpp_area.getAttribute("uid"); + attribute = ""; + for (input of wpp_area.querySelectorAll('input')) { + if (input.getAttribute("data_type") == "name") { + wpp['name'] = input.value; + } else if (input.getAttribute("data_type") == "type") { + wpp['type'] = input.value; + } else if (input.getAttribute("data_type") == "attribute") { + attribute = input.value; + if (!(input.value in wpp['attributes'])) { + console.log("adding attribute"); + wpp['attributes'][input.value] = []; + } + + } else if (input.getAttribute("data_type") == "value") { + wpp['attributes'][attribute].push(input.value); + } + } + world_info_data[uid]['wpp'] = wpp; + send_world_info(uid); } //--------------------------------------------UI to Server Functions---------------------------------- diff --git a/templates/story flyout.html b/templates/story flyout.html index b5b57fbf..23faa3c4 100644 --- a/templates/story flyout.html +++ b/templates/story flyout.html @@ -67,31 +67,33 @@
\ No newline at end of file diff --git a/templates/templates.html b/templates/templates.html index 5c16a62d..dac6063b 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -19,15 +19,11 @@Type: | -+ | |
Name: | -+ |