mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-22 22:47:45 +01:00
Redo fix. Fix for actions structure to not error out when asking for next_id when the actions list is empty.
This commit is contained in:
parent
5f92cbc231
commit
221f264fa7
10
aiserver.py
10
aiserver.py
@ -2787,7 +2787,7 @@ def actionback():
|
||||
vars.recentback = True
|
||||
remove_story_chunk(last_key + 1)
|
||||
#for the redo to not get out of whack, need to reset the max # in the actions sequence
|
||||
vars.actions.set_next_id(vars.actions.get_last_key())
|
||||
vars.actions.set_next_id(last_key)
|
||||
elif(len(vars.genseqs) == 0):
|
||||
emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."})
|
||||
else:
|
||||
@ -2800,7 +2800,6 @@ def actionredo():
|
||||
genout = [{"generated_text": item['Text']} for item in vars.actions_metadata[vars.actions.get_last_key()+1]['Alternative Text'] if (item["Previous Selection"]==True)]
|
||||
if len(genout) > 0:
|
||||
genout = genout + [{"generated_text": item['Text']} for item in vars.actions_metadata[vars.actions.get_last_key()+1]['Alternative Text'] if (item["Pinned"]==True) and (item["Previous Selection"]==False)]
|
||||
|
||||
if len(genout) == 1:
|
||||
vars.actions_metadata[vars.actions.get_last_key()+1]['Alternative Text'] = [item for item in vars.actions_metadata[vars.actions.get_last_key()+1]['Alternative Text'] if (item["Previous Selection"]!=True)]
|
||||
genresult(genout[0]['generated_text'], flash=True)
|
||||
@ -2811,6 +2810,7 @@ def actionredo():
|
||||
|
||||
# Send sequences to UI for selection
|
||||
genout = [[item['Text'], "redo"] for item in vars.actions_metadata[vars.actions.get_last_key()+1]['Alternative Text'] if (item["Previous Selection"]==True)]
|
||||
|
||||
emit('from_server', {'cmd': 'genseqs', 'data': genout}, broadcast=True)
|
||||
else:
|
||||
emit('from_server', {'cmd': 'popuperror', 'data': "There's nothing to undo"}, broadcast=True)
|
||||
@ -3195,8 +3195,10 @@ def genresult(genout, flash=True):
|
||||
if not vars.quiet:
|
||||
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
||||
|
||||
print("1: {}\n\n".format(genout))
|
||||
# Format output before continuing
|
||||
genout = applyoutputformatting(genout)
|
||||
print("2: {}\n\n".format(genout))
|
||||
|
||||
vars.lua_koboldbridge.feedback = genout
|
||||
|
||||
@ -4618,8 +4620,6 @@ def loadRequest(loadpath, filename=None):
|
||||
emit('from_server', {'cmd': 'hidegenseqs', 'data': ''}, broadcast=True)
|
||||
print("{0}Story loaded from {1}!{2}".format(colors.GREEN, filename, colors.END))
|
||||
|
||||
print([k for k in vars.actions])
|
||||
print([k for k in vars.actions_metadata])
|
||||
send_debug()
|
||||
|
||||
#==================================================================#
|
||||
@ -5030,7 +5030,7 @@ def send_debug():
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
debug_info = "{}Actions: {}\n".format(debug_info, vars.actions.get_last_key())
|
||||
debug_info = "{}Actions: {}\n".format(debug_info, [k for k in vars.actions])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
|
@ -19,10 +19,16 @@ class KoboldStoryRegister(collections.OrderedDict):
|
||||
return self.popitem()[1]
|
||||
|
||||
def get_first_key(self) -> int:
|
||||
return next(iter(self))
|
||||
if len(self) == 0:
|
||||
return -1
|
||||
else:
|
||||
return next(iter(self))
|
||||
|
||||
def get_last_key(self) -> int:
|
||||
return next(reversed(self))
|
||||
if len(self) == 0:
|
||||
return -1
|
||||
else:
|
||||
return next(reversed(self))
|
||||
|
||||
def __getitem__(self, k: int) -> str:
|
||||
return super().__getitem__(k)
|
||||
|
Loading…
x
Reference in New Issue
Block a user