From 61fd06d0c77e0d1bc0d1fe075be2a2e00bf27443 Mon Sep 17 00:00:00 2001 From: somebody Date: Sat, 12 Nov 2022 21:33:31 -0600 Subject: [PATCH] Fix loading for type --- koboldai_settings.py | 14 ++++++++++++-- static/koboldai.js | 2 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index 62f12924..e339c266 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1727,7 +1727,7 @@ class KoboldWorldInfo(object): 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, wi_type="World Info", use_wpp=False, + comment, wi_type="wi", 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: @@ -1928,9 +1928,18 @@ class KoboldWorldInfo(object): "images": self.image_store } + def upgrade_entry(self, wi_entry: dict) -> dict: + # If we do not have a type, or it is incorrect, set to WI. + if wi_entry.get("type") not in ["constant", "chatcharacter", "wi"]: + wi_entry["type"] = "wi" + + return wi_entry + def load_json(self, data, folder=None): if "images" in data: self.image_store = data["images"] + + data["entries"] = {k: self.upgrade_entry(v) for k,v in data["entries"].items()} if folder is None: self.world_info = {int(x): data['entries'][x] for x in data['entries']} @@ -1939,6 +1948,7 @@ class KoboldWorldInfo(object): #Add the item for uid, item in data['entries'].items(): start_time = time.time() + self.add_item(item['title'] if 'title' in item else item['key'][0], item['key'] if 'key' in item else [], item['keysecondary'] if 'keysecondary' in item else [], @@ -1946,7 +1956,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"), + wi_type=item["type"], 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.js b/static/koboldai.js index d34bafa2..874c9c63 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -125,7 +125,6 @@ const chat = { lastEdit: null, get useV2() { - console.log(`v2 Check: style=${this.style} mode=${story.mode}`) return [ this.STYLES.MESSAGES, this.STYLES.BUBBLES @@ -478,7 +477,6 @@ function do_story_text_updates(action) { } function do_prompt(data) { - console.log("[prompt]", data); var elements_to_change = document.getElementsByClassName("var_sync_story_prompt"); for (item of elements_to_change) { //clear out the item first