Merge branch 'united' of https://github.com/henk717/KoboldAI into henk717-united

This commit is contained in:
ebolam 2022-01-22 17:57:33 -05:00
commit bdd358f40f
3 changed files with 52 additions and 11 deletions

View File

@ -2291,8 +2291,12 @@ def loadsettings():
# Allow the models to override some settings
#==================================================================#
def loadmodelsettings():
model_js_config = str(model_config).partition(' ')[2]
js = json.loads(model_js_config)
try:
model_js_config = str(model_config).partition(' ')[2]
js = json.loads(model_js_config)
except Exception as e:
model_js_config = open(vars.custmodpth.replace('/', '_') + "/config.json", "r")
js = json.load(model_js_config)
if("badwordsids" in js):
vars.badwordsids = js["badwordsids"]
if("temp" in js):
@ -3340,6 +3344,7 @@ def update_story_chunk(idx: Union[int, str]):
# prompt might not have been shown yet (with a "Generating story..."
# message instead).
refresh_story()
setgamesaved(False)
return
idx = (vars.actions.get_last_key() if len(vars.actions) else 0) + 1
@ -3349,6 +3354,8 @@ def update_story_chunk(idx: Union[int, str]):
else:
# Actions are 0 based, but in chunks 0 is the prompt.
# So the chunk index is one more than the corresponding action index.
if(idx - 1 not in vars.actions):
return
text = vars.actions[idx - 1]
item = html.escape(text)
@ -3357,7 +3364,9 @@ def update_story_chunk(idx: Union[int, str]):
chunk_text = f'<chunk n="{idx}" id="n{idx}" tabindex="-1">{formatforhtml(item)}</chunk>'
emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text}}, broadcast=True)
setgamesaved(False)
#If we've set the auto save flag, we'll now save the file
if vars.autosave and (".json" in vars.savedir):
save()
@ -3368,6 +3377,7 @@ def update_story_chunk(idx: Union[int, str]):
#==================================================================#
def remove_story_chunk(idx: int):
emit('from_server', {'cmd': 'removechunk', 'data': idx}, broadcast=True)
setgamesaved(False)
#==================================================================#
@ -3488,7 +3498,9 @@ def inlineedit(chunk, data):
"Edited": True}]
vars.actions_metadata[chunk-1]['Selected Text'] = data
vars.actions[chunk-1] = data
else:
print(f"WARNING: Attempted to edit non-existent chunk {chunk}")
setgamesaved(False)
update_story_chunk(chunk)
emit('from_server', {'cmd': 'texteffect', 'data': chunk}, broadcast=True)
@ -3513,6 +3525,8 @@ def inlinedelete(chunk):
"Edited": False}] + vars.actions_metadata[chunk-1]['Alternative Text']
vars.actions_metadata[chunk-1]['Selected Text'] = ''
vars.actions[chunk-1] = ''
else:
print(f"WARNING: Attempted to delete non-existent chunk {chunk}")
setgamesaved(False)
remove_story_chunk(chunk)
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)

View File

@ -1614,7 +1614,12 @@ return function(_python, _bridged)
error("module '" .. modname .. "' not found:" .. table.concat(errors))
return
end
local retval = old_loadfile(path, "t", env)()
local f, err = old_loadfile(path, "t", env)
if err ~= nil then
error(err)
return
end
local retval = (f())
package_loaded[env][modname] = retval == nil or retval
return package_loaded[env][modname], path
end
@ -1664,12 +1669,33 @@ return function(_python, _bridged)
bridged.print(table.concat(args, "\t"))
end
local function redirected_warn(...)
local args = table.pack(...)
for i = 1, args.n do
args[i] = tostring(args[i])
local function _redirected_warn()
local do_warning = true
local control_table = {
["@on"] = function()
do_warning = true
end,
["@off"] = function()
do_warning = false
end,
}
return function(...)
local args = table.pack(...)
if args.n == 1 and type(args[1]) == "string" and args[1]:sub(1, 1) == "@" then
local f = control_table[args[1]]
if f ~= nil then
f()
end
return
end
if not do_warning then
return
end
for i = 1, args.n do
args[i] = tostring(args[i])
end
bridged.warn(table.concat(args, "\t"))
end
bridged.warn(table.concat(args, "\t"))
end
local sandbox_template_env = {
@ -1829,7 +1855,7 @@ return function(_python, _bridged)
envs[universe].load = _safe_load(env)
envs[universe].require = _safe_require(env)
envs[universe].print = redirected_print
envs[universe].warn = redirected_warn
envs[universe].warn = _redirected_warn()
env._G = env
end
return env

View File

@ -1243,6 +1243,7 @@ body.connected .popupfooter, .popupfooter.always-available {
-o-transition: all 0.15s ease-in;
-webkit-transition: all 0.15s ease-in;
transition: all 0.15s ease-in;
white-space: pre-wrap;
}
.seqselitem:hover {