diff --git a/aiserver.py b/aiserver.py index f5046b7b..f6a53114 100644 --- a/aiserver.py +++ b/aiserver.py @@ -7475,16 +7475,16 @@ def loadRequest(loadpath, filename=None): start_time = time.time() if(isinstance(loadpath, str)): #Original UI only sends the story name and assumes it's always a .json file... here we check to see if it's a directory to load that way - if not isinstance(loadpath, dict) and not os.path.exists(loadpath): - if os.path.exists(loadpath.replace(".json", "")): - loadpath = loadpath.replace(".json", "") + if not isinstance(loadpath, dict) and not os.path.exists(loadpath): + if os.path.exists(loadpath.replace(".json", "")): + loadpath = loadpath.replace(".json", "") - if not isinstance(loadpath, dict) and os.path.isdir(loadpath): - if not valid_v3_story(loadpath): - raise RuntimeError(f"Tried to load {loadpath}, a non-save directory.") - koboldai_vars.update_story_path_structure(loadpath) - loadpath = os.path.join(loadpath, "story.json") - + if not isinstance(loadpath, dict) and os.path.isdir(loadpath): + if not valid_v3_story(loadpath): + raise RuntimeError(f"Tried to load {loadpath}, a non-save directory.") + koboldai_vars.update_story_path_structure(loadpath) + loadpath = os.path.join(loadpath, "story.json") + with open(loadpath, "r", encoding="utf-8") as file: js = json.load(file) from_file=loadpath