mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Include koboldai_vars.save_story().
This commit is contained in:
@@ -7273,7 +7273,7 @@ def save():
|
|||||||
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
|
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
|
||||||
same_story = True
|
same_story = True
|
||||||
if os.path.exists("stories/{}".format(save_name)):
|
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)
|
json_data = json.load(settings_file)
|
||||||
if 'story_id' in json_data:
|
if 'story_id' in json_data:
|
||||||
same_story = json_data['story_id'] == koboldai_vars.story_id
|
same_story = json_data['story_id'] == koboldai_vars.story_id
|
||||||
|
@@ -938,7 +938,7 @@ class story_settings(settings):
|
|||||||
while os.path.exists(self.save_paths.base):
|
while os.path.exists(self.save_paths.base):
|
||||||
try:
|
try:
|
||||||
# If the stories share a story id, overwrite the existing one.
|
# 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)
|
j = json.load(file)
|
||||||
if self.story_id == j["story_id"]:
|
if self.story_id == j["story_id"]:
|
||||||
break
|
break
|
||||||
@@ -960,7 +960,7 @@ class story_settings(settings):
|
|||||||
v2_path = os.path.join("stories", f"{self.story_name}_v2.json")
|
v2_path = os.path.join("stories", f"{self.story_name}_v2.json")
|
||||||
if os.path.exists(v2_path):
|
if os.path.exists(v2_path):
|
||||||
logger.info("Migrating v2 save")
|
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)
|
v2j = json.load(file)
|
||||||
|
|
||||||
if v2j["story_id"] == self.story_id:
|
if v2j["story_id"] == self.story_id:
|
||||||
@@ -968,7 +968,7 @@ class story_settings(settings):
|
|||||||
else:
|
else:
|
||||||
logger.warning(f"Story mismatch in v2 migration. Existing file had story id {v2j['story_id']} but we have {self.story_id}")
|
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())
|
file.write(self.to_json())
|
||||||
self.gamesaved = True
|
self.gamesaved = True
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user