From f63099ce33b2285dd37c908da8d4e781c8342aa7 Mon Sep 17 00:00:00 2001 From: ebolam Date: Thu, 22 Sep 2022 12:49:00 -0400 Subject: [PATCH] Fix --- koboldai_settings.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index c47cc461..f241f779 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -156,16 +156,7 @@ class koboldai_vars(object): #we're going to split our actions by sentence for better context. We'll add in which actions the sentence covers. Prompt will be added at a -1 ID actions = {i: self.actions[i] for i in range(len(self.actions))} actions[-1] = self.prompt - try: - action_text = self.prompt + str(self.actions) - except: - print("=====================DEBUG=======================") - print(self.prompt) - print(str(self.actions)) - print("=====================END DEBUG=======================") - print() - print() - raise + action_text = self.prompt + str(self.actions) ###########action_text_split = [sentence, actions used in sentence, token length, included in AI context]################ action_text_split = [[x+" ", [], 0 if self.tokenizer is None else len(self.tokenizer.encode(x+" ")), False] for x in re.split("(?<=[.!?])\s+", action_text)] #The last action shouldn't have the extra space from the sentence splitting, so let's remove it @@ -972,7 +963,10 @@ class KoboldStoryRegister(object): self.__init__(self.socketio, self.story_settings, self.koboldai_vars, sequence=sequence, tokenizer=self.tokenizer) def __str__(self): - return "".join([x['Selected Text'] for ignore, x in sorted(self.actions.items())]) + if len(self.actions) > 0: + return "".join([x['Selected Text'] for ignore, x in sorted(self.actions.items())]) + else: + return "" def __repr__(self): return self.__str__()