retry bug fix

This commit is contained in:
ebolam
2022-08-29 08:30:36 -04:00
parent d6a91fae44
commit c10e534275
2 changed files with 8 additions and 4 deletions

View File

@@ -4706,11 +4706,13 @@ def generate(txt, minimum, maximum, found_entries=None):
else:
genout = [{"generated_text": utils.decodenewlines(tokenizer.decode(tokens[-already_generated:]))} for tokens in genout]
print([applyoutputformatting(x["generated_text"]) for x in genout])
koboldai_vars.actions.append_options([applyoutputformatting(x["generated_text"]) for x in genout])
genout = [{"generated_text": x['text']} for x in koboldai_vars.actions.get_current_options()]
if(len(genout) == 1):
genresult(genout[0]["generated_text"])
#koboldai_vars.actions.append(applyoutputformatting(genout[0]["generated_text"]))
else:
koboldai_vars.actions.append_options([applyoutputformatting(x["generated_text"]) for x in genout])
genout = [{"generated_text": x['text']} for x in koboldai_vars.actions.get_current_options()]
if(koboldai_vars.lua_koboldbridge.restart_sequence is not None and koboldai_vars.lua_koboldbridge.restart_sequence > 0):
genresult(genout[koboldai_vars.lua_koboldbridge.restart_sequence-1]["generated_text"])
else:
@@ -7115,7 +7117,7 @@ def UI_2_redo(data):
@socketio.on('retry')
def UI_2_retry(data):
if len(koboldai_vars.actions.get_current_options()) == 0:
if len(koboldai_vars.actions.get_current_options_no_edits()) == 0:
UI_2_back(None)
koboldai_vars.actions.clear_unused_options()
koboldai_vars.lua_koboldbridge.feedback = None

View File

@@ -812,6 +812,7 @@ class KoboldStoryRegister(object):
def append(self, text):
self.clear_unused_options()
print("setting action_count {} -> {}".format(self.action_count, self.action_count+1))
self.action_count+=1
if self.action_count in self.actions:
if self.actions[self.action_count]["Selected Text"] != text:
@@ -947,6 +948,7 @@ class KoboldStoryRegister(object):
del self.actions[action_step]['Options'][option_number]
#If this is the current spot in the story, advance
if action_step-1 == self.action_count:
print("setting action_count {} -> {}".format(self.action_count, self.action_count+1))
self.action_count+=1
self.socketio.emit("var_changed", {"classname": "actions", "name": "Action Count", "old_value": None, "value":self.action_count}, broadcast=True, room="UI_2")
process_variable_changes(self.socketio, "story", 'actions', {"id": action_step, 'action': self.actions[action_step]}, None)
@@ -961,6 +963,7 @@ class KoboldStoryRegister(object):
self.actions[action_id]["Options"].append({"text": self.actions[action_id]["Selected Text"], "Pinned": False, "Previous Selection": True, "Edited": False})
self.actions[action_id]["Selected Text"] = ""
self.actions[action_id]['Selected Text Length'] = 0
print("setting action_count {} -> {}".format(self.action_count, self.action_count-1))
self.action_count -= 1
process_variable_changes(self.socketio, "story", 'actions', {"id": action_id, 'action': self.actions[action_id]}, None)
self.set_game_saved()
@@ -1051,7 +1054,6 @@ class KoboldStoryRegister(object):
process_variable_changes(self.socketio, "story", 'actions', {"id": self.action_count+1, 'action': self.actions[self.action_count+1]}, None)
def set_probabilites(self, probabilities, action_id=None):
print(probabilities)
if action_id is None:
action_id = self.action_count
if action_id in self.actions: