diff --git a/aiserver.py b/aiserver.py index 0ca8683f..807f4c84 100644 --- a/aiserver.py +++ b/aiserver.py @@ -5538,48 +5538,9 @@ def load_story_v1(js): if("worldinfo" in js): num = 0 for wi in js["worldinfo"]: - koboldai_vars.worldinfo.append({ - "key": wi["key"], - "keysecondary": wi.get("keysecondary", ""), - "content": wi["content"], - "comment": wi.get("comment", ""), - "folder": wi.get("folder", None), - "num": num, - "init": True, - "selective": wi.get("selective", False), - "constant": wi.get("constant", False), - "uid": None, - }) koboldai_vars.worldinfo_v2.add_item([x.strip() for x in wi["key"].split(",")][0], wi["key"], wi.get("keysecondary", ""), wi.get("folder", "root"), wi.get("constant", False), wi["content"], wi.get("comment", "")) - - - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in koboldai_vars.worldinfo_u): - break - koboldai_vars.worldinfo_u[uid] = koboldai_vars.worldinfo[-1] - koboldai_vars.worldinfo[-1]["uid"] = uid - if(koboldai_vars.worldinfo[-1]["folder"] is not None): - koboldai_vars.wifolders_u[koboldai_vars.worldinfo[-1]["folder"]].append(koboldai_vars.worldinfo[-1]) - num += 1 - - for uid in koboldai_vars.wifolders_l + [None]: - koboldai_vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in koboldai_vars.worldinfo_u): - break - try: - koboldai_vars.worldinfo_u[uid] = koboldai_vars.worldinfo[-1] - except: - print(koboldai_vars.worldinfo) - koboldai_vars.worldinfo[-1]["uid"] = uid - if(koboldai_vars.worldinfo[-1]["folder"] is not None): - koboldai_vars.wifolders_u[koboldai_vars.worldinfo[-1]["folder"]].append(koboldai_vars.worldinfo[-1]) - stablesortwi() - koboldai_vars.worldinfo_i = [wi for wi in koboldai_vars.worldinfo if wi["init"]] # Save path for save button koboldai_vars.savedir = loadpath @@ -5766,29 +5727,24 @@ def importgame(): def importAidgRequest(id): exitModes() - urlformat = "https://prompts.aidg.club/api/" + urlformat = "https://aetherroom.club/api/" req = requests.get(urlformat+id) - if(req.status_code == 200): js = req.json() # Import game state + + koboldai_vars.create_story("") koboldai_vars.gamestarted = True koboldai_vars.prompt = js["promptContent"] koboldai_vars.memory = js["memory"] koboldai_vars.authornote = js["authorsNote"] - koboldai_vars.authornotetemplate = "[Author's note: <|>]" - koboldai_vars.actions.reset() - koboldai_vars.actions_metadata = {} - koboldai_vars.worldinfo = [] - koboldai_vars.worldinfo_i = [] - koboldai_vars.worldinfo_u = {} - koboldai_vars.wifolders_d = {} - koboldai_vars.wifolders_l = [] - koboldai_vars.wifolders_u = {uid: [] for uid in koboldai_vars.wifolders_d} - koboldai_vars.lastact = "" - koboldai_vars.submission = "" - koboldai_vars.lastctx = "" + + + if not koboldai_vars.memory: + koboldai_vars.memory = "" + if not koboldai_vars.authornote: + koboldai_vars.authornote = "" num = 0 for wi in js["worldInfos"]: @@ -5804,28 +5760,12 @@ def importAidgRequest(id): "constant": wi.get("constant", False), "uid": None, }) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in koboldai_vars.worldinfo_u): - break - koboldai_vars.worldinfo_u[uid] = koboldai_vars.worldinfo[-1] - koboldai_vars.worldinfo[-1]["uid"] = uid - if(koboldai_vars.worldinfo[-1]["folder"]) is not None: - koboldai_vars.wifolders_u[koboldai_vars.worldinfo[-1]["folder"]].append(koboldai_vars.worldinfo[-1]) - num += 1 - - for uid in koboldai_vars.wifolders_l + [None]: - koboldai_vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in koboldai_vars.worldinfo_u): - break - koboldai_vars.worldinfo_u[uid] = koboldai_vars.worldinfo[-1] - koboldai_vars.worldinfo[-1]["uid"] = uid - if(koboldai_vars.worldinfo[-1]["folder"] is not None): - koboldai_vars.wifolders_u[koboldai_vars.worldinfo[-1]["folder"]].append(koboldai_vars.worldinfo[-1]) - stablesortwi() - koboldai_vars.worldinfo_i = [wi for wi in koboldai_vars.worldinfo if wi["init"]] + + koboldai_vars.worldinfo_v2.add_item([x.strip() for x in wi["keys"].split(",")][0], wi["keys"], wi.get("keysecondary", ""), + wi.get("folder", "root"), wi.get("constant", False), + wi["entry"], wi.get("comment", "")) + + # Reset current save koboldai_vars.savedir = getcwd()+"\\stories" @@ -6674,6 +6614,17 @@ def UI_2_load_softprompt(data): print("Load softprompt: {}".format(data)) spRequest(data) +#==================================================================# +# Event triggered when aidg.club loaded +#==================================================================# +@socketio.on('load_aidg_club') +def UI_2_load_aidg_club(data): + print("Load aidg.club: {}".format(data)) + importAidgRequest(data) + + + + #==================================================================# # Test #==================================================================# diff --git a/koboldai_settings.py b/koboldai_settings.py index fa3e1295..5a41fb3b 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -1011,6 +1011,7 @@ class KoboldWorldInfo(object): def reorder(self, uid, before): self.add_item_to_folder(uid, self.world_info[before]['folder'], before=before) + self.sync_world_info_to_old_format() def send_to_ui(self): self.socketio.emit("world_info_folder", {x: self.world_info_folder[x] for x in self.world_info_folder}, broadcast=True, room="UI_2") @@ -1048,7 +1049,7 @@ class KoboldWorldInfo(object): "comment": self.world_info[x]['comment'], "constant": self.world_info[x]['constant'], "content": self.world_info[x]['content'], - "folder": self.world_info[x]['folder'], + "folder": folder_entries[self.world_info[x]['folder']], "init": True, "key": ",".join(self.world_info[x]['key']), "keysecondary": ",".join(self.world_info[x]['keysecondary']), diff --git a/static/koboldai.js b/static/koboldai.js index ef0223c0..a846ffb7 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1498,7 +1498,7 @@ function preserve_game_space(preserve) { document.getElementById('preserve_game_space_setting').checked = true; } else { setCookie("preserve_game_space", "false"); - r.style.setProperty('--setting_menu_closed_width_no_pins_width', '450px'); + r.style.setProperty('--setting_menu_closed_width_no_pins_width', 'var(--flyout_menu_width)'); if (document.getElementById('preserve_game_space_setting').checked) { //not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so.... document.getElementById('preserve_game_space_setting').parentNode.click(); @@ -2090,7 +2090,6 @@ function close_menus() { //close popup menus document.getElementById('popup').classList.add("hidden"); document.getElementById('loadmodelcontainer').classList.add("hidden"); - document.getElementById('loadcontainer').classList.add("hidden"); document.getElementById('save-confirm').classList.add("hidden"); document.getElementById('error_message').classList.add("hidden"); diff --git a/templates/popups.html b/templates/popups.html index 63a33cea..104984da 100644 --- a/templates/popups.html +++ b/templates/popups.html @@ -52,23 +52,6 @@ - -
- + + - +