@@ -5268,6 +5268,7 @@ def do_POST(self):
52685268 if targetfile=="unload_model": #special request to simply unload model
52695269 print("Admin: Received request to unload model")
52705270 global_memory["restart_target"] = "unload_model"
5271+ global_memory["restart_model"] = ""
52715272 resp = {"success": True}
52725273 else:
52735274 dirpath = os.path.abspath(args.admindir)
@@ -7833,7 +7834,6 @@ def setuptunnel(global_memory, has_sd):
78337834 # This script will help setup a cloudflared tunnel for accessing KoboldCpp/Croco.Cpp over the internet
78347835 # It should work out of the box on both linux and windows
78357836 try:
7836-
78377837 # import subprocess
78387838 # import re
78397839
@@ -8309,6 +8309,15 @@ def main(launch_args, default_args):
83098309 args.admin = False
83108310 print("\nWARNING: Admin was set without selecting an admin directory. Admin cannot be used.\n")
83118311
8312+ # Check if admin exists, if not add a default to the directory to allow remote model loading without a config
8313+ if args.admin and args.admindir:
8314+ dirpath = os.path.abspath(args.admindir)
8315+ opts = [f for f in sorted(os.listdir(dirpath)) if (f.endswith(".kcpps") or f.endswith(".kcppt")) and os.path.isfile(os.path.join(dirpath, f))]
8316+ if len(opts) == 0:
8317+ with open(os.path.join(dirpath, "Default.kcpps"), "w") as f:
8318+ f.write("{}")
8319+ print("\nAdmin directory was empty, default file generated.\n")
8320+
83128321 if not args.admin: #run in single process mode
83138322 if args.remotetunnel and not args.prompt and not args.benchmark and not args.cli:
83148323 setuptunnel(global_memory, True if args.sdmodel else False)
@@ -8372,14 +8381,15 @@ def main(launch_args, default_args):
83728381 if args.admin and args.admindir:
83738382 dirpath = os.path.abspath(args.admindir)
83748383 targetfilepath = os.path.join(dirpath, restart_target)
8375- if os.path.exists(targetfilepath) or restart_target=="unload_model":
8384+ if ( os.path.exists(targetfilepath) or restart_target=="unload_model") :
83768385 print("Terminating old process...")
83778386 global_memory["load_complete"] = False
83788387 kcpp_instance.terminate()
83798388 kcpp_instance.join(timeout=10) # Ensure process is stopped
83808389 kcpp_instance = None
83818390 print("Restarting KoboldCpp...")
83828391 fault_recovery_mode = True
8392+
83838393 if restart_target=="unload_model":
83848394 reload_from_new_args(vars(default_args))
83858395 args.model_param = None
0 commit comments