From 6fb2b4ddb39c5cad69d534ea0df63f760b8244d5 Mon Sep 17 00:00:00 2001 From: ebolam Date: Wed, 7 Sep 2022 15:44:25 -0400 Subject: [PATCH] Fix for auto saving on creating new story --- aiserver.py | 5 ++++- koboldai_settings.py | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/aiserver.py b/aiserver.py index cd94b889..7d1a86a7 100644 --- a/aiserver.py +++ b/aiserver.py @@ -4018,10 +4018,13 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False, data = f"\n\n> {data}\n" # "Chat" mode + print(koboldai_vars.chatmode) + print(koboldai_vars.gamestarted) if(koboldai_vars.chatmode and koboldai_vars.gamestarted): data = re.sub(r'\n+', ' ', data) if(len(data)): data = f"\n{koboldai_vars.chatname}: {data}\n" + print("Chat Mode Data: {}".format(data)) # If we're not continuing, store a copy of the raw input if(data != ""): @@ -7172,7 +7175,7 @@ def UI_2_submit(data): koboldai_vars.lua_koboldbridge.feedback = None koboldai_vars.recentrng = koboldai_vars.recentrngm = None if koboldai_vars.actions.action_count == -1: - actionsubmit(data['data'], actionmode=0) + actionsubmit(data['data'], actionmode=koboldai_vars.actionmode) else: actionsubmit(data['data'], actionmode=koboldai_vars.actionmode) diff --git a/koboldai_settings.py b/koboldai_settings.py index a6c7fd52..abf0c6fb 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -85,12 +85,11 @@ class koboldai_vars(object): #If we can figure out a way to get flask sessions into/through the lua bridge we could re-enable story_name = 'default' if story_name in self._story_settings: - self._story_settings[story_name].reset() else: self._story_settings[story_name] = story_settings(self.socketio) if json_data is not None: - self._story_settings[story_name].from_json(json_data) + self.load_story(sotry_name, json_data) self._story_settings['default'].send_to_ui() def story_list(self): @@ -517,7 +516,6 @@ class story_settings(settings): self.gamestarted = False # Whether the game has started (disables UI elements) self.gamesaved = True # Whether or not current game is saved self.autosave = False # Whether or not to automatically save after each action - self.no_save = False #Temporary disable save (doesn't save with the file) self.prompt = "" # Prompt self.memory = "" # Text submitted to memory field self.authornote = "" # Text submitted to Author's Note field @@ -568,6 +566,9 @@ class story_settings(settings): self.context = [] self.last_story_load = None + #must be at bottom + self.no_save = False #Temporary disable save (doesn't save with the file) + def save_story(self): if not self.no_save: if self.prompt != "" or self.memory != "" or self.authornote != "" or len(self.actions) > 0 or len(self.worldinfo_v2) > 0: @@ -592,8 +593,10 @@ class story_settings(settings): self.gamesaved = True def reset(self): + self.no_save = True self.socketio.emit("reset_story", {}, broadcast=True, room="UI_2") self.__init__(self.socketio, self.koboldai_vars, tokenizer=self.tokenizer) + self.no_save = False def __setattr__(self, name, value): new_variable = name not in self.__dict__