Merge branch 'united' of https://github.com/henk717/KoboldAI into henk717-united
This commit is contained in:
commit
bdd358f40f
14
aiserver.py
14
aiserver.py
|
@ -2291,8 +2291,12 @@ def loadsettings():
|
|||
# Allow the models to override some settings
|
||||
#==================================================================#
|
||||
def loadmodelsettings():
|
||||
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)
|
||||
|
@ -3358,6 +3365,8 @@ 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,6 +3498,8 @@ 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)
|
||||
|
@ -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)
|
||||
|
|
32
bridge.lua
32
bridge.lua
|
@ -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,13 +1669,34 @@ return function(_python, _bridged)
|
|||
bridged.print(table.concat(args, "\t"))
|
||||
end
|
||||
|
||||
local function redirected_warn(...)
|
||||
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
|
||||
end
|
||||
|
||||
local sandbox_template_env = {
|
||||
assert = assert,
|
||||
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue