Merge pull request #51 from VE-FORBRYDERNE/patch
Fix AI output text flash showing up on wrong chunk
This commit is contained in:
commit
756a7941f2
23
aiserver.py
23
aiserver.py
|
@ -2141,23 +2141,25 @@ def actionsubmit(data, actionmode=0, force_submit=False, force_prompt_gen=False,
|
||||||
genout.append({"generated_text": vars.lua_koboldbridge.outputs[i+1]})
|
genout.append({"generated_text": vars.lua_koboldbridge.outputs[i+1]})
|
||||||
assert type(genout[-1]["generated_text"]) is str
|
assert type(genout[-1]["generated_text"]) is str
|
||||||
if(len(genout) == 1):
|
if(len(genout) == 1):
|
||||||
genresult(genout[0]["generated_text"])
|
genresult(genout[0]["generated_text"], flash=False)
|
||||||
|
refresh_story()
|
||||||
|
if(len(vars.actions) > 0):
|
||||||
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1}, broadcast=True)
|
||||||
if(vars.lua_koboldbridge.restart_sequence is not None):
|
if(vars.lua_koboldbridge.restart_sequence is not None):
|
||||||
refresh_story()
|
|
||||||
data = ""
|
data = ""
|
||||||
force_submit = True
|
force_submit = True
|
||||||
disable_recentrng = True
|
disable_recentrng = True
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if(vars.lua_koboldbridge.restart_sequence is not None and vars.lua_koboldbridge.restart_sequence > 0):
|
if(vars.lua_koboldbridge.restart_sequence is not None and vars.lua_koboldbridge.restart_sequence > 0):
|
||||||
genresult(genout[vars.lua_koboldbridge.restart_sequence-1]["generated_text"])
|
genresult(genout[vars.lua_koboldbridge.restart_sequence-1]["generated_text"], flash=False)
|
||||||
refresh_story()
|
refresh_story()
|
||||||
data = ""
|
data = ""
|
||||||
force_submit = True
|
force_submit = True
|
||||||
disable_recentrng = True
|
disable_recentrng = True
|
||||||
continue
|
continue
|
||||||
genselect(genout)
|
genselect(genout)
|
||||||
refresh_story()
|
refresh_story()
|
||||||
set_aibusy(0)
|
set_aibusy(0)
|
||||||
emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True)
|
emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True)
|
||||||
break
|
break
|
||||||
|
@ -2629,7 +2631,7 @@ def generate(txt, minimum, maximum, found_entries=None):
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Deal with a single return sequence from generate()
|
# Deal with a single return sequence from generate()
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def genresult(genout):
|
def genresult(genout, flash=True):
|
||||||
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
||||||
|
|
||||||
# Format output before continuing
|
# Format output before continuing
|
||||||
|
@ -2646,7 +2648,8 @@ def genresult(genout):
|
||||||
else:
|
else:
|
||||||
vars.actions.append(genout)
|
vars.actions.append(genout)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
if(flash):
|
||||||
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1 if len(vars.actions) else 0}, broadcast=True)
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Send generator sequences to the UI for selection
|
# Send generator sequences to the UI for selection
|
||||||
|
@ -2675,7 +2678,7 @@ def selectsequence(n):
|
||||||
if(len(vars.lua_koboldbridge.feedback) != 0):
|
if(len(vars.lua_koboldbridge.feedback) != 0):
|
||||||
vars.actions.append(vars.lua_koboldbridge.feedback)
|
vars.actions.append(vars.lua_koboldbridge.feedback)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1 if len(vars.actions) else 0}, broadcast=True)
|
||||||
emit('from_server', {'cmd': 'hidegenseqs', 'data': ''}, broadcast=True)
|
emit('from_server', {'cmd': 'hidegenseqs', 'data': ''}, broadcast=True)
|
||||||
vars.genseqs = []
|
vars.genseqs = []
|
||||||
|
|
||||||
|
@ -2751,7 +2754,7 @@ def sendtocolab(txt, min, max):
|
||||||
# Add formatted text to Actions array and refresh the game screen
|
# Add formatted text to Actions array and refresh the game screen
|
||||||
#vars.actions.append(genout)
|
#vars.actions.append(genout)
|
||||||
#refresh_story()
|
#refresh_story()
|
||||||
#emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0})
|
#emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1 if len(vars.actions) else 0})
|
||||||
|
|
||||||
set_aibusy(0)
|
set_aibusy(0)
|
||||||
else:
|
else:
|
||||||
|
@ -3447,7 +3450,7 @@ def ikrequest(txt):
|
||||||
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
||||||
vars.actions.append(genout)
|
vars.actions.append(genout)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1 if len(vars.actions) else 0}, broadcast=True)
|
||||||
|
|
||||||
set_aibusy(0)
|
set_aibusy(0)
|
||||||
else:
|
else:
|
||||||
|
@ -3506,7 +3509,7 @@ def oairequest(txt, min, max):
|
||||||
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
print("{0}{1}{2}".format(colors.CYAN, genout, colors.END))
|
||||||
vars.actions.append(genout)
|
vars.actions.append(genout)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() + 1 if len(vars.actions) else 0}, broadcast=True)
|
||||||
|
|
||||||
set_aibusy(0)
|
set_aibusy(0)
|
||||||
else:
|
else:
|
||||||
|
|
17
bridge.lua
17
bridge.lua
|
@ -1511,6 +1511,18 @@ return function(_python, _bridged)
|
||||||
koboldbridge.logging_name = nil
|
koboldbridge.logging_name = nil
|
||||||
koboldbridge.filename = nil
|
koboldbridge.filename = nil
|
||||||
|
|
||||||
|
local sandbox_require_builtins = {
|
||||||
|
coroutine = true,
|
||||||
|
package = true,
|
||||||
|
string = true,
|
||||||
|
utf8 = true,
|
||||||
|
table = true,
|
||||||
|
math = true,
|
||||||
|
io = true,
|
||||||
|
os = true,
|
||||||
|
debug = true,
|
||||||
|
}
|
||||||
|
|
||||||
local old_load = load
|
local old_load = load
|
||||||
local function _safe_load(_g)
|
local function _safe_load(_g)
|
||||||
return function(chunk, chunkname, mode, env)
|
return function(chunk, chunkname, mode, env)
|
||||||
|
@ -1541,6 +1553,11 @@ return function(_python, _bridged)
|
||||||
if modname == "bridge" then
|
if modname == "bridge" then
|
||||||
return function() return env.kobold, env.koboldcore end
|
return function() return env.kobold, env.koboldcore end
|
||||||
end
|
end
|
||||||
|
for k, v in pairs(sandbox_require_builtins) do
|
||||||
|
if modname == k then
|
||||||
|
return env[k]
|
||||||
|
end
|
||||||
|
end
|
||||||
if type(modname) == "number" then
|
if type(modname) == "number" then
|
||||||
modname = tostring(modname)
|
modname = tostring(modname)
|
||||||
elseif type(modname) ~= "string" then
|
elseif type(modname) ~= "string" then
|
||||||
|
|
Loading…
Reference in New Issue