From d3bedfcbdab9814abaca0fa762b215753fe85c60 Mon Sep 17 00:00:00 2001 From: jojorne Date: Wed, 22 Feb 2023 15:42:56 -0300 Subject: [PATCH] Include koboldai_vars.save_story(). --- aiserver.py | 2 +- koboldai_settings.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aiserver.py b/aiserver.py index a55edee0..21689acd 100644 --- a/aiserver.py +++ b/aiserver.py @@ -7273,7 +7273,7 @@ def save(): save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled" same_story = True if os.path.exists("stories/{}".format(save_name)): - with open("stories/{}/story.json".format(save_name), "r") as settings_file: + with open("stories/{}/story.json".format(save_name), "r", encoding="utf-8") as settings_file: json_data = json.load(settings_file) if 'story_id' in json_data: same_story = json_data['story_id'] == koboldai_vars.story_id diff --git a/koboldai_settings.py b/koboldai_settings.py index d85e2919..40e87ccc 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -938,7 +938,7 @@ class story_settings(settings): while os.path.exists(self.save_paths.base): try: # If the stories share a story id, overwrite the existing one. - with open(self.save_paths.story, "r") as file: + with open(self.save_paths.story, "r", encoding="utf-8") as file: j = json.load(file) if self.story_id == j["story_id"]: break @@ -960,7 +960,7 @@ class story_settings(settings): v2_path = os.path.join("stories", f"{self.story_name}_v2.json") if os.path.exists(v2_path): logger.info("Migrating v2 save") - with open(v2_path, "r") as file: + with open(v2_path, "r", encoding="utf-8") as file: v2j = json.load(file) if v2j["story_id"] == self.story_id: @@ -968,7 +968,7 @@ class story_settings(settings): else: logger.warning(f"Story mismatch in v2 migration. Existing file had story id {v2j['story_id']} but we have {self.story_id}") - with open(self.save_paths.story, "w") as file: + with open(self.save_paths.story, "w", encoding="utf-8") as file: file.write(self.to_json()) self.gamesaved = True