Lua API fixes for deleting/editing story chunks

This commit is contained in:
Gnome Ann 2021-12-31 18:28:03 -05:00
parent 7241188408
commit ccfafe4f0a
2 changed files with 12 additions and 10 deletions

View File

@ -1249,7 +1249,7 @@ def lua_get_numseqs():
def lua_set_numseqs(numseqs): def lua_set_numseqs(numseqs):
assert type(numseqs) in (int, float) and numseqs >= 1 assert type(numseqs) in (int, float) and numseqs >= 1
print(colors.GREEN + f"{lua_log_format_name(vars.lua_koboldbridge.logging_name)} set numseqs to {int(numseqs)}" + colors.END) print(colors.GREEN + f"{lua_log_format_name(vars.lua_koboldbridge.logging_name)} set numseqs to {int(numseqs)}" + colors.END)
vars.genamt = int(numseqs) vars.numseqs = int(numseqs)
#==================================================================# #==================================================================#
# Check if a setting exists with the given name # Check if a setting exists with the given name
@ -1411,7 +1411,7 @@ def lua_set_chunk(k, v):
if(vars.lua_koboldbridge.userstate == "genmod"): if(vars.lua_koboldbridge.userstate == "genmod"):
del vars._actions[chunk-1] del vars._actions[chunk-1]
vars.lua_deleted.add(chunk) vars.lua_deleted.add(chunk)
if(vars._actions is not vars.actions): if(not hasattr(vars, "_actions") or vars._actions is not vars.actions):
del vars.actions[chunk-1] del vars.actions[chunk-1]
else: else:
if(k == 0): if(k == 0):
@ -3118,6 +3118,7 @@ def inlineedit(chunk, data):
return return
vars.prompt = data vars.prompt = data
else: else:
if(chunk-1 in vars.actions):
vars.actions[chunk-1] = data vars.actions[chunk-1] = data
update_story_chunk(chunk) update_story_chunk(chunk)
@ -3137,6 +3138,7 @@ def inlinedelete(chunk):
emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."}) emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."})
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True) emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
else: else:
if(chunk-1 in vars.actions):
del vars.actions[chunk-1] del vars.actions[chunk-1]
remove_story_chunk(chunk) remove_story_chunk(chunk)
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True) emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)

View File

@ -1916,6 +1916,9 @@ return function(_python, _bridged)
koboldbridge.generating = true koboldbridge.generating = true
koboldbridge.generated_cols = 0 koboldbridge.generated_cols = 0
koboldbridge.generated = {} koboldbridge.generated = {}
if koboldbridge.inmod ~= nil then
r = koboldbridge.inmod()
end
for i = 1, kobold.settings.numseqs do for i = 1, kobold.settings.numseqs do
koboldbridge.generated[i] = {} koboldbridge.generated[i] = {}
end end
@ -1923,9 +1926,6 @@ return function(_python, _bridged)
for i = 1, kobold.num_outputs do for i = 1, kobold.num_outputs do
koboldbridge.outputs[i] = {} koboldbridge.outputs[i] = {}
end end
if koboldbridge.inmod ~= nil then
r = koboldbridge.inmod()
end
return r return r
end end