From 32a0d7c453df24e9bf829aa76a9b2e31ecca8731 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Sun, 26 Dec 2021 12:49:28 -0500 Subject: [PATCH] More Lua API fixes * Removed `vars.model_orig` * `requirex()` in bridge.lua now maintains a separate module cache for each userscript instead of using the same cache for all userscripts * `vars.lua_deleted` and `vars.lua_edited` are now erased right before running the input modifiers instead of right before each time the generation modifiers are run --- aiserver.py | 9 ++++----- bridge.lua | 14 ++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/aiserver.py b/aiserver.py index 63d3aed5..a4f12997 100644 --- a/aiserver.py +++ b/aiserver.py @@ -85,7 +85,6 @@ class vars: submission = "" # Same as above, but after applying input formatting lastctx = "" # The last context submitted to the generator model = "" # Model ID string chosen at startup - model_orig = "" # Original model string before being changed by auto model type detection model_type = "" # Model Type (Automatically taken from the model config) noai = False # Runs the script without starting up the transformers pipeline aibusy = False # Stops submissions while the AI is working @@ -190,7 +189,7 @@ def getModelSelection(): while(vars.model == ''): modelsel = input("Model #> ") if(modelsel.isnumeric() and int(modelsel) > 0 and int(modelsel) <= len(modellist)): - vars.model = vars.model_orig = modellist[int(modelsel)-1][1] + vars.model = modellist[int(modelsel)-1][1] else: print("{0}Please enter a valid selection.{1}".format(colors.RED, colors.END)) @@ -371,7 +370,7 @@ parser.add_argument("--override_rename", action='store_true', help="Renaming sto parser.add_argument("--configname", help="Force a fixed configuration name to aid with config management.") args = parser.parse_args() -vars.model = vars.model_orig = args.model; +vars.model = args.model; if args.remote: vars.remote = True; @@ -1448,6 +1447,8 @@ def lua_is_custommodel(): #==================================================================# def execute_inmod(): vars.lua_logname = ... + vars.lua_edited = set() + vars.lua_deleted = set() try: tpool.execute(vars.lua_koboldbridge.execute_inmod) except lupa.LuaError as e: @@ -1461,8 +1462,6 @@ def execute_inmod(): set_aibusy(0) def execute_genmod(): - vars.lua_edited = set() - vars.lua_deleted = set() vars.lua_koboldbridge.execute_genmod() def execute_outmod(): diff --git a/bridge.lua b/bridge.lua index 39acc222..01c54760 100644 --- a/bridge.lua +++ b/bridge.lua @@ -1038,7 +1038,7 @@ return function(_python, _bridged) ---@param t KoboldLib ---@return string function KoboldLib_getters.model(t) - return bridged.vars.model_orig + return bridged.vars.model end ---@param t KoboldLib @@ -1526,7 +1526,7 @@ return function(_python, _bridged) end local old_loadfile = loadfile - local old_package_loaded = package.loaded + local package_loaded = {} ---@type table