Merge branch 'united' of https://github.com/henk717/KoboldAI into henk717-united
This commit is contained in:
commit
bdd358f40f
18
aiserver.py
18
aiserver.py
|
@ -2291,8 +2291,12 @@ def loadsettings():
|
||||||
# Allow the models to override some settings
|
# Allow the models to override some settings
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def loadmodelsettings():
|
def loadmodelsettings():
|
||||||
model_js_config = str(model_config).partition(' ')[2]
|
try:
|
||||||
js = json.loads(model_js_config)
|
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):
|
if("badwordsids" in js):
|
||||||
vars.badwordsids = js["badwordsids"]
|
vars.badwordsids = js["badwordsids"]
|
||||||
if("temp" in js):
|
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..."
|
# prompt might not have been shown yet (with a "Generating story..."
|
||||||
# message instead).
|
# message instead).
|
||||||
refresh_story()
|
refresh_story()
|
||||||
|
setgamesaved(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
idx = (vars.actions.get_last_key() if len(vars.actions) else 0) + 1
|
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:
|
else:
|
||||||
# Actions are 0 based, but in chunks 0 is the prompt.
|
# Actions are 0 based, but in chunks 0 is the prompt.
|
||||||
# So the chunk index is one more than the corresponding action index.
|
# 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]
|
text = vars.actions[idx - 1]
|
||||||
|
|
||||||
item = html.escape(text)
|
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>'
|
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)
|
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 we've set the auto save flag, we'll now save the file
|
||||||
if vars.autosave and (".json" in vars.savedir):
|
if vars.autosave and (".json" in vars.savedir):
|
||||||
save()
|
save()
|
||||||
|
@ -3368,6 +3377,7 @@ def update_story_chunk(idx: Union[int, str]):
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def remove_story_chunk(idx: int):
|
def remove_story_chunk(idx: int):
|
||||||
emit('from_server', {'cmd': 'removechunk', 'data': idx}, broadcast=True)
|
emit('from_server', {'cmd': 'removechunk', 'data': idx}, broadcast=True)
|
||||||
|
setgamesaved(False)
|
||||||
|
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
@ -3488,6 +3498,8 @@ def inlineedit(chunk, data):
|
||||||
"Edited": True}]
|
"Edited": True}]
|
||||||
vars.actions_metadata[chunk-1]['Selected Text'] = data
|
vars.actions_metadata[chunk-1]['Selected Text'] = data
|
||||||
vars.actions[chunk-1] = data
|
vars.actions[chunk-1] = data
|
||||||
|
else:
|
||||||
|
print(f"WARNING: Attempted to edit non-existent chunk {chunk}")
|
||||||
|
|
||||||
setgamesaved(False)
|
setgamesaved(False)
|
||||||
update_story_chunk(chunk)
|
update_story_chunk(chunk)
|
||||||
|
@ -3513,6 +3525,8 @@ def inlinedelete(chunk):
|
||||||
"Edited": False}] + vars.actions_metadata[chunk-1]['Alternative Text']
|
"Edited": False}] + vars.actions_metadata[chunk-1]['Alternative Text']
|
||||||
vars.actions_metadata[chunk-1]['Selected Text'] = ''
|
vars.actions_metadata[chunk-1]['Selected Text'] = ''
|
||||||
vars.actions[chunk-1] = ''
|
vars.actions[chunk-1] = ''
|
||||||
|
else:
|
||||||
|
print(f"WARNING: Attempted to delete non-existent chunk {chunk}")
|
||||||
setgamesaved(False)
|
setgamesaved(False)
|
||||||
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)
|
||||||
|
|
40
bridge.lua
40
bridge.lua
|
@ -1614,7 +1614,12 @@ return function(_python, _bridged)
|
||||||
error("module '" .. modname .. "' not found:" .. table.concat(errors))
|
error("module '" .. modname .. "' not found:" .. table.concat(errors))
|
||||||
return
|
return
|
||||||
end
|
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
|
package_loaded[env][modname] = retval == nil or retval
|
||||||
return package_loaded[env][modname], path
|
return package_loaded[env][modname], path
|
||||||
end
|
end
|
||||||
|
@ -1664,12 +1669,33 @@ return function(_python, _bridged)
|
||||||
bridged.print(table.concat(args, "\t"))
|
bridged.print(table.concat(args, "\t"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function redirected_warn(...)
|
local function _redirected_warn()
|
||||||
local args = table.pack(...)
|
local do_warning = true
|
||||||
for i = 1, args.n do
|
local control_table = {
|
||||||
args[i] = tostring(args[i])
|
["@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
|
||||||
bridged.warn(table.concat(args, "\t"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local sandbox_template_env = {
|
local sandbox_template_env = {
|
||||||
|
@ -1829,7 +1855,7 @@ return function(_python, _bridged)
|
||||||
envs[universe].load = _safe_load(env)
|
envs[universe].load = _safe_load(env)
|
||||||
envs[universe].require = _safe_require(env)
|
envs[universe].require = _safe_require(env)
|
||||||
envs[universe].print = redirected_print
|
envs[universe].print = redirected_print
|
||||||
envs[universe].warn = redirected_warn
|
envs[universe].warn = _redirected_warn()
|
||||||
env._G = env
|
env._G = env
|
||||||
end
|
end
|
||||||
return env
|
return env
|
||||||
|
|
|
@ -1243,6 +1243,7 @@ body.connected .popupfooter, .popupfooter.always-available {
|
||||||
-o-transition: all 0.15s ease-in;
|
-o-transition: all 0.15s ease-in;
|
||||||
-webkit-transition: all 0.15s ease-in;
|
-webkit-transition: all 0.15s ease-in;
|
||||||
transition: all 0.15s ease-in;
|
transition: all 0.15s ease-in;
|
||||||
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.seqselitem:hover {
|
.seqselitem:hover {
|
||||||
|
|
Loading…
Reference in New Issue