diff --git a/aiserver.py b/aiserver.py index 7bba54c4..3559ccdf 100644 --- a/aiserver.py +++ b/aiserver.py @@ -8643,7 +8643,7 @@ def UI_2_edit_world_info(data): koboldai_vars.worldinfo_v2.edit_item(data['uid'], data['title'], data['key'], data['keysecondary'], data['folder'], data['constant'], data['manual_text'], - data['comment'], wpp=data['wpp'], use_wpp=data['use_wpp']) + data['comment'], wi_type=data["type"], wpp=data['wpp'], use_wpp=data['use_wpp']) #==================================================================# diff --git a/koboldai_settings.py b/koboldai_settings.py index 41132474..62f12924 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1726,8 +1726,9 @@ class KoboldWorldInfo(object): if self.socketio is not None: 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, manual_text, - comment, use_wpp=False, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}, + def add_item(self, title, key, keysecondary, folder, constant, manual_text, + comment, wi_type="World Info", use_wpp=False, + wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}, v1_uid=None, recalc=True, sync=True, send_to_ui=True): if len(self.world_info) == 0: uid = 0 @@ -1772,6 +1773,7 @@ class KoboldWorldInfo(object): 'manual_text': manual_text, "content": content, "comment": comment, + "type": wi_type, "token_length": token_length, "selective": len(keysecondary) > 0, "used_in_game": constant, @@ -1801,7 +1803,7 @@ class KoboldWorldInfo(object): ignore = self.koboldai_vars.calc_ai_text() return uid - def edit_item(self, uid, title, key, keysecondary, folder, constant, manual_text, comment, use_wpp=False, before=None, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}): + def edit_item(self, uid, title, key, keysecondary, folder, constant, manual_text, comment, wi_type, use_wpp=False, before=None, wpp={'name': "", 'type': "", 'format': "W++", 'attributes': {}}): logger.debug("Editing World Info {}: {}".format(uid, title)) old_folder = self.world_info[uid]['folder'] #move the world info entry if the folder changed or if there is a new order requested @@ -1836,6 +1838,7 @@ class KoboldWorldInfo(object): 'manual_text': manual_text, "content": content, "comment": comment, + "type": wi_type, "token_length": token_length, "selective": len(keysecondary) > 0, "used_in_game": constant, @@ -1943,6 +1946,7 @@ class KoboldWorldInfo(object): item['constant'] if 'constant' in item else False, item['manual_text'] if 'manual_text' in item else item['content'], item['comment'] if 'comment' in item else '', + item.get('type', "World Info"), use_wpp=item['use_wpp'] if 'use_wpp' in item else False, wpp=item['wpp'] if 'wpp' in item else {'name': "", 'type': "", 'format': "W++", 'attributes': {}}, recalc=False, sync=False) diff --git a/static/koboldai.css b/static/koboldai.css index d0c9fe03..1f40bb29 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -1087,6 +1087,19 @@ td.server_vars { filter: brightness(90%); } +.world_info_always_include { + display: inline-block; +} + +.world_info_upper_container { + display: flex; + justify-content: space-between; +} + +.world_info_type { + margin: 0px; +} + .world_info_text { width: auto; margin: 0 0px 0px; diff --git a/static/koboldai.js b/static/koboldai.js index 3400c4dc..14b23561 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1895,6 +1895,30 @@ function world_info_entry(data) { reader.readAsDataURL(file); }); + const wiTypeSelector = world_info_card.querySelector(".world_info_type"); + wiTypeSelector.value = world_info_data[data.uid].type; + wiTypeSelector.classList.remove("pulse"); + wiTypeSelector.addEventListener("change", function(event) { + console.log(event); + switch (wiTypeSelector.value) { + case "Chat Character": + world_info_data[data.uid].constant = true; + break; + case "Memory": + world_info_data[data.uid].constant = true; + break; + case "World Info": + world_info_data[data.uid].constant = false; + break; + default: + reportError("Error", `Unknown WI type ${wiTypeSelector.value}`); + return; + } + world_info_data[data.uid].type = wiTypeSelector.value; + send_world_info(data.uid); + this.classList.add("pulse"); + }) + tags = world_info_card.querySelector('.world_info_tag_primary_area'); tags.id = "world_info_tags_"+data.uid; //add tag content here @@ -2078,27 +2102,6 @@ function world_info_entry(data) { this.classList.add("pulse"); } comment.classList.remove("pulse"); - constant_area = world_info_card.querySelector('.world_info_always_include'); - constant_area.id = "world_info_toggle_area_"+data.uid; - if (document.getElementById("world_info_constant_"+data.uid)) { - constant = document.getElementById("world_info_constant_"+data.uid); - } else { - constant = document.createElement("input"); - constant.id = "world_info_constant_"+data.uid; - constant.setAttribute("type", "checkbox"); - constant.setAttribute("uid", data.uid); - constant.setAttribute("data-size", "mini"); - constant.setAttribute("data-onstyle", "success"); - constant.setAttribute("data-toggle", "toggle"); - constant.onchange = function () { - world_info_data[this.getAttribute('uid')]['constant'] = this.checked; - send_world_info(this.getAttribute('uid')); - this.classList.add("pulse"); - } - constant_area.append(constant); - } - constant.checked = data.constant; - constant.classList.remove("pulse"); //Let's figure out the order to insert this card var found = false; diff --git a/templates/templates.html b/templates/templates.html index bc663d50..3486c3ce 100644 --- a/templates/templates.html +++ b/templates/templates.html @@ -11,18 +11,26 @@ X -
- Always Include + +
+
+ Use W++ +
+ +
+ +
Requires one of:
And (if present):
-
- Use W++ -