From aedd7e966bcff06511ffe77750bd49fa11fbb2a8 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 4 Jul 2022 19:08:30 -0400 Subject: [PATCH 01/14] Fix for edit files --- static/application.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/application.js b/static/application.js index c89364b4..aef93daa 100644 --- a/static/application.js +++ b/static/application.js @@ -3344,6 +3344,10 @@ function popup_breadcrumbs(data) { function popup_edit_file(data) { var popup_list = document.getElementById('popup_list'); + var accept = document.getElementById("popup_accept"); + accept.classList.add("btn-secondary"); + accept.classList.remove("btn-primary"); + accept.textContent = "Save"; //first, let's clear out our existing data while (popup_list.firstChild) { popup_list.removeChild(popup_list.firstChild); @@ -3354,6 +3358,7 @@ function popup_edit_file(data) { var textarea = document.getElementById("filecontents"); socket.emit("popup_change_file", {"file": textarea.getAttribute("filename"), "data": textarea.value}); document.getElementById("popup").classList.add("hidden"); + this.classList.add("hidden"); }; var textarea = document.createElement("textarea"); @@ -3364,7 +3369,9 @@ function popup_edit_file(data) { textarea.value = data.text; textarea.onblur = function () { var accept = document.getElementById("popup_accept"); - accept.classList.remove("disabled"); + accept.classList.remove("hidden"); + accept.classList.remove("btn-secondary"); + accept.classList.add("btn-primary"); }; popup_list.append(textarea); From d91ed3141d014bcec578b051a5384395842bb220 Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 15 Jul 2022 12:30:02 -0400 Subject: [PATCH 02/14] Fix for non ascii files in edit mode --- aiserver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiserver.py b/aiserver.py index a21cdcdd..564d6ce0 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6198,9 +6198,9 @@ def popup_edit(data): return if session['popup_jailed_dir'] is None: - emit("popup_edit_file", {"file": data, "text": open(data, 'r').read()}); + emit("popup_edit_file", {"file": data, "text": open(data, 'r', encoding='utf-8').read()}); elif session['popup_jailed_dir'] in data: - emit("popup_edit_file", {"file": data, "text": open(data, 'r').read()}); + emit("popup_edit_file", {"file": data, "text": open(data, 'r', encoding='utf-8').read()}); else: print("User is trying to delete files in your server outside the jail. Blocked. Jailed Dir: {} Requested Dir: {}".format(session['popup_jailed_dir'], data)) From 23a031d852d6890e4fa6bde197a3aeb70ec7714b Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 19 Jul 2022 13:40:55 -0400 Subject: [PATCH 03/14] Fix for aidg.club website being taken read-only --- aiserver.py | 166 ++++++++++++++++++++++++++++------------------------ 1 file changed, 91 insertions(+), 75 deletions(-) diff --git a/aiserver.py b/aiserver.py index 9d34fe9c..6c29982b 100644 --- a/aiserver.py +++ b/aiserver.py @@ -5782,85 +5782,101 @@ def importgame(): def importAidgRequest(id): exitModes() - urlformat = "https://prompts.aidg.club/api/" - req = requests.get(urlformat+id) + #prompts.aidg.club is dead now. They are serving up a sqllite db, so we'll download that if it's not already saved and use that instead + #urlformat = "https://prompts.aidg.club/api/" + #req = requests.get(urlformat+id) + + if not os.path.exists("aidgclub.db"): + import urllib.request + urllib.request.urlretrieve("https://prompts.aidg.club/backup.db", "aidgclub.db") - if(req.status_code == 200): - js = req.json() + import sqlite3 + con = sqlite3.connect("aidgclub.db") + cur = con.cursor() + js = {} + sql = "select * from Prompts where CorrelationId = {}".format(id) + for row in cur.execute(sql): + js['promptContent'] = row[6] + js['memory'] = row[3] + js['authorsNote'] = row[1] + js['worldInfos'] = [] + for row in cur.execute("select * from WorldInfos where PromptId = {}".format(id)): + js['worldInfos'].append({'keys': row[2], 'entry': row[1]}) + - # Import game state - vars.gamestarted = True - vars.prompt = js["promptContent"] - vars.memory = js["memory"] - vars.authornote = js["authorsNote"] - vars.authornotetemplate = "[Author's note: <|>]" - vars.actions = structures.KoboldStoryRegister() - vars.actions_metadata = {} - vars.worldinfo = [] - vars.worldinfo_i = [] - vars.worldinfo_u = {} - vars.wifolders_d = {} - vars.wifolders_l = [] - vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} - vars.lastact = "" - vars.submission = "" - vars.lastctx = "" - - if not vars.memory: - vars.memory = "" - if not vars.authornote: - vars.authornote = "" - - num = 0 - for wi in js["worldInfos"]: - vars.worldinfo.append({ - "key": wi["keys"], - "keysecondary": wi.get("keysecondary", ""), - "content": wi["entry"], - "comment": wi.get("comment", ""), - "folder": wi.get("folder", None), - "num": num, - "init": True, - "selective": wi.get("selective", False), - "constant": wi.get("constant", False), - "uid": None, - }) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in vars.worldinfo_u): - break - vars.worldinfo_u[uid] = vars.worldinfo[-1] - vars.worldinfo[-1]["uid"] = uid - if(vars.worldinfo[-1]["folder"]) is not None: - vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) - num += 1 + # Import game state + vars.gamestarted = True + vars.prompt = js["promptContent"] + vars.memory = js["memory"] + vars.authornote = js["authorsNote"] + vars.authornotetemplate = "[Author's note: <|>]" + vars.actions = structures.KoboldStoryRegister() + vars.actions_metadata = {} + vars.worldinfo = [] + vars.worldinfo_i = [] + vars.worldinfo_u = {} + vars.wifolders_d = {} + vars.wifolders_l = [] + vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} + vars.lastact = "" + vars.submission = "" + vars.lastctx = "" + + if not vars.memory: + vars.memory = "" + if not vars.authornote: + vars.authornote = "" + + num = 0 + for wi in js["worldInfos"]: + vars.worldinfo.append({ + "key": wi["keys"], + "keysecondary": wi.get("keysecondary", ""), + "content": wi["entry"], + "comment": wi.get("comment", ""), + "folder": wi.get("folder", None), + "num": num, + "init": True, + "selective": wi.get("selective", False), + "constant": wi.get("constant", False), + "uid": None, + }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid + if(vars.worldinfo[-1]["folder"]) is not None: + vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) + num += 1 - for uid in vars.wifolders_l + [None]: - vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in vars.worldinfo_u): - break - vars.worldinfo_u[uid] = vars.worldinfo[-1] - vars.worldinfo[-1]["uid"] = uid - if(vars.worldinfo[-1]["folder"] is not None): - vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) - stablesortwi() - vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]] + for uid in vars.wifolders_l + [None]: + vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid + if(vars.worldinfo[-1]["folder"] is not None): + vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) + stablesortwi() + vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]] - # Reset current save - vars.savedir = getcwd()+"\\stories" - - # Refresh game screen - vars.laststory = None - emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) - setgamesaved(False) - sendwi() - emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) - emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) - emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate}, broadcast=True) - refresh_story() - emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) + # Reset current save + vars.savedir = getcwd()+"\\stories" + + # Refresh game screen + vars.laststory = None + emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) + setgamesaved(False) + sendwi() + emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) + emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) + emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate}, broadcast=True) + refresh_story() + emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) #==================================================================# # Import World Info JSON file From 9c1fc5af8b3c432ddfe39614f36a3e079f7f596f Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 19 Jul 2022 14:02:27 -0400 Subject: [PATCH 04/14] Revert "Fix for edit files" This reverts commit aedd7e966bcff06511ffe77750bd49fa11fbb2a8. --- static/application.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/static/application.js b/static/application.js index 2388aa23..8defc342 100644 --- a/static/application.js +++ b/static/application.js @@ -3434,10 +3434,6 @@ function popup_breadcrumbs(data) { function popup_edit_file(data) { var popup_list = document.getElementById('popup_list'); - var accept = document.getElementById("popup_accept"); - accept.classList.add("btn-secondary"); - accept.classList.remove("btn-primary"); - accept.textContent = "Save"; //first, let's clear out our existing data while (popup_list.firstChild) { popup_list.removeChild(popup_list.firstChild); @@ -3448,7 +3444,6 @@ function popup_edit_file(data) { var textarea = document.getElementById("filecontents"); socket.emit("popup_change_file", {"file": textarea.getAttribute("filename"), "data": textarea.value}); document.getElementById("popup").classList.add("hidden"); - this.classList.add("hidden"); }; var textarea = document.createElement("textarea"); @@ -3459,9 +3454,7 @@ function popup_edit_file(data) { textarea.value = data.text; textarea.onblur = function () { var accept = document.getElementById("popup_accept"); - accept.classList.remove("hidden"); - accept.classList.remove("btn-secondary"); - accept.classList.add("btn-primary"); + accept.classList.remove("disabled"); }; popup_list.append(textarea); From c3fdee68a80150a04533e339841d2929e36a9ee9 Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 19 Jul 2022 16:53:45 -0400 Subject: [PATCH 05/14] Revert "Revert "Fix for edit files"" This reverts commit 9c1fc5af8b3c432ddfe39614f36a3e079f7f596f. --- static/application.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/static/application.js b/static/application.js index 8defc342..2388aa23 100644 --- a/static/application.js +++ b/static/application.js @@ -3434,6 +3434,10 @@ function popup_breadcrumbs(data) { function popup_edit_file(data) { var popup_list = document.getElementById('popup_list'); + var accept = document.getElementById("popup_accept"); + accept.classList.add("btn-secondary"); + accept.classList.remove("btn-primary"); + accept.textContent = "Save"; //first, let's clear out our existing data while (popup_list.firstChild) { popup_list.removeChild(popup_list.firstChild); @@ -3444,6 +3448,7 @@ function popup_edit_file(data) { var textarea = document.getElementById("filecontents"); socket.emit("popup_change_file", {"file": textarea.getAttribute("filename"), "data": textarea.value}); document.getElementById("popup").classList.add("hidden"); + this.classList.add("hidden"); }; var textarea = document.createElement("textarea"); @@ -3454,7 +3459,9 @@ function popup_edit_file(data) { textarea.value = data.text; textarea.onblur = function () { var accept = document.getElementById("popup_accept"); - accept.classList.remove("disabled"); + accept.classList.remove("hidden"); + accept.classList.remove("btn-secondary"); + accept.classList.add("btn-primary"); }; popup_list.append(textarea); From f58064e72cba670468731097239fa3d698ac2bbb Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 19 Jul 2022 16:54:32 -0400 Subject: [PATCH 06/14] Revert "Fix for aidg.club website being taken read-only" This reverts commit 23a031d852d6890e4fa6bde197a3aeb70ec7714b. --- aiserver.py | 166 ++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 91 deletions(-) diff --git a/aiserver.py b/aiserver.py index 6c29982b..9d34fe9c 100644 --- a/aiserver.py +++ b/aiserver.py @@ -5782,101 +5782,85 @@ def importgame(): def importAidgRequest(id): exitModes() - #prompts.aidg.club is dead now. They are serving up a sqllite db, so we'll download that if it's not already saved and use that instead - #urlformat = "https://prompts.aidg.club/api/" - #req = requests.get(urlformat+id) - - if not os.path.exists("aidgclub.db"): - import urllib.request - urllib.request.urlretrieve("https://prompts.aidg.club/backup.db", "aidgclub.db") + urlformat = "https://prompts.aidg.club/api/" + req = requests.get(urlformat+id) - import sqlite3 - con = sqlite3.connect("aidgclub.db") - cur = con.cursor() - js = {} - sql = "select * from Prompts where CorrelationId = {}".format(id) - for row in cur.execute(sql): - js['promptContent'] = row[6] - js['memory'] = row[3] - js['authorsNote'] = row[1] - js['worldInfos'] = [] - for row in cur.execute("select * from WorldInfos where PromptId = {}".format(id)): - js['worldInfos'].append({'keys': row[2], 'entry': row[1]}) - + if(req.status_code == 200): + js = req.json() - # Import game state - vars.gamestarted = True - vars.prompt = js["promptContent"] - vars.memory = js["memory"] - vars.authornote = js["authorsNote"] - vars.authornotetemplate = "[Author's note: <|>]" - vars.actions = structures.KoboldStoryRegister() - vars.actions_metadata = {} - vars.worldinfo = [] - vars.worldinfo_i = [] - vars.worldinfo_u = {} - vars.wifolders_d = {} - vars.wifolders_l = [] - vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} - vars.lastact = "" - vars.submission = "" - vars.lastctx = "" - - if not vars.memory: - vars.memory = "" - if not vars.authornote: - vars.authornote = "" - - num = 0 - for wi in js["worldInfos"]: - vars.worldinfo.append({ - "key": wi["keys"], - "keysecondary": wi.get("keysecondary", ""), - "content": wi["entry"], - "comment": wi.get("comment", ""), - "folder": wi.get("folder", None), - "num": num, - "init": True, - "selective": wi.get("selective", False), - "constant": wi.get("constant", False), - "uid": None, - }) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in vars.worldinfo_u): - break - vars.worldinfo_u[uid] = vars.worldinfo[-1] - vars.worldinfo[-1]["uid"] = uid - if(vars.worldinfo[-1]["folder"]) is not None: - vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) - num += 1 + # Import game state + vars.gamestarted = True + vars.prompt = js["promptContent"] + vars.memory = js["memory"] + vars.authornote = js["authorsNote"] + vars.authornotetemplate = "[Author's note: <|>]" + vars.actions = structures.KoboldStoryRegister() + vars.actions_metadata = {} + vars.worldinfo = [] + vars.worldinfo_i = [] + vars.worldinfo_u = {} + vars.wifolders_d = {} + vars.wifolders_l = [] + vars.wifolders_u = {uid: [] for uid in vars.wifolders_d} + vars.lastact = "" + vars.submission = "" + vars.lastctx = "" + + if not vars.memory: + vars.memory = "" + if not vars.authornote: + vars.authornote = "" + + num = 0 + for wi in js["worldInfos"]: + vars.worldinfo.append({ + "key": wi["keys"], + "keysecondary": wi.get("keysecondary", ""), + "content": wi["entry"], + "comment": wi.get("comment", ""), + "folder": wi.get("folder", None), + "num": num, + "init": True, + "selective": wi.get("selective", False), + "constant": wi.get("constant", False), + "uid": None, + }) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid + if(vars.worldinfo[-1]["folder"]) is not None: + vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) + num += 1 - for uid in vars.wifolders_l + [None]: - vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) - while(True): - uid = int.from_bytes(os.urandom(4), "little", signed=True) - if(uid not in vars.worldinfo_u): - break - vars.worldinfo_u[uid] = vars.worldinfo[-1] - vars.worldinfo[-1]["uid"] = uid - if(vars.worldinfo[-1]["folder"] is not None): - vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) - stablesortwi() - vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]] + for uid in vars.wifolders_l + [None]: + vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None}) + while(True): + uid = int.from_bytes(os.urandom(4), "little", signed=True) + if(uid not in vars.worldinfo_u): + break + vars.worldinfo_u[uid] = vars.worldinfo[-1] + vars.worldinfo[-1]["uid"] = uid + if(vars.worldinfo[-1]["folder"] is not None): + vars.wifolders_u[vars.worldinfo[-1]["folder"]].append(vars.worldinfo[-1]) + stablesortwi() + vars.worldinfo_i = [wi for wi in vars.worldinfo if wi["init"]] - # Reset current save - vars.savedir = getcwd()+"\\stories" - - # Refresh game screen - vars.laststory = None - emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) - setgamesaved(False) - sendwi() - emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) - emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) - emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate}, broadcast=True) - refresh_story() - emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) + # Reset current save + vars.savedir = getcwd()+"\\stories" + + # Refresh game screen + vars.laststory = None + emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) + setgamesaved(False) + sendwi() + emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) + emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) + emit('from_server', {'cmd': 'setanotetemplate', 'data': vars.authornotetemplate}, broadcast=True) + refresh_story() + emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) #==================================================================# # Import World Info JSON file From a0475ba049c48554f69d5c77eb41a25df1ad4d61 Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 19 Jul 2022 18:16:01 -0400 Subject: [PATCH 07/14] Moved emit action on fire browser to button rather than icon for easier clicking --- templates/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index 3e099118..2132021c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -340,7 +340,7 @@
Select A Soft Prompt To Use
- +
@@ -354,7 +354,7 @@
Select userscripts to load; drag-and-drop to reorder
- +
[AVAILABLE]
From 907cf74b13d57fd14820e0903fcf547a4286594e Mon Sep 17 00:00:00 2001 From: ebolam Date: Fri, 22 Jul 2022 13:58:20 -0400 Subject: [PATCH 08/14] Added status bar for downloading models --- aiserver.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ utils.py | 12 +++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/aiserver.py b/aiserver.py index 9d34fe9c..d7ca3841 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1305,9 +1305,60 @@ def patch_causallm(model): Embedding._koboldai_patch_causallm_model = model return model +def patch_transformers_download(): + global transformers + import copy, requests, tqdm, time + class Send_to_socketio(object): + def write(self, bar): + bar = bar.replace("\r", "") + try: + emit('from_server', {'cmd': 'model_load_status', 'data': bar.replace(" ", " ")}, broadcast=True) + eventlet.sleep(seconds=0) + except: + pass + def http_get( + url: str, + temp_file: transformers.utils.hub.BinaryIO, + proxies=None, + resume_size=0, + headers: transformers.utils.hub.Optional[transformers.utils.hub.Dict[str, str]] = None, + file_name: transformers.utils.hub.Optional[str] = None, + ): + """ + Download remote file. Do not gobble up errors. + """ + headers = copy.deepcopy(headers) + if resume_size > 0: + headers["Range"] = f"bytes={resume_size}-" + r = requests.get(url, stream=True, proxies=proxies, headers=headers) + transformers.utils.hub._raise_for_status(r) + content_length = r.headers.get("Content-Length") + total = resume_size + int(content_length) if content_length is not None else None + # `tqdm` behavior is determined by `utils.logging.is_progress_bar_enabled()` + # and can be set using `utils.logging.enable/disable_progress_bar()` + progress = tqdm.tqdm( + unit="B", + unit_scale=True, + unit_divisor=1024, + total=total, + initial=resume_size, + desc=f"Downloading {file_name}" if file_name is not None else "Downloading", + file=Send_to_socketio(), + ) + for chunk in r.iter_content(chunk_size=1024): + if chunk: # filter out keep-alive new chunks + progress.update(len(chunk)) + temp_file.write(chunk) + progress.close() + + transformers.utils.hub.http_get = http_get + def patch_transformers(): global transformers + + patch_transformers_download() + old_from_pretrained = PreTrainedModel.from_pretrained.__func__ @classmethod def new_from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): @@ -6377,6 +6428,7 @@ if __name__ == "__main__": vars.flaskwebgui = True FlaskUI(app, socketio=socketio, start_server="flask-socketio", maximized=True, close_server_on_exit=True).run() except: + pass import webbrowser webbrowser.open_new('http://localhost:{0}'.format(port)) print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:{1}/{2}" diff --git a/utils.py b/utils.py index dc2c97d0..d20d376d 100644 --- a/utils.py +++ b/utils.py @@ -172,6 +172,16 @@ def num_layers(config): #==================================================================# # Downloads huggingface checkpoints using aria2c if possible #==================================================================# +from flask_socketio import emit +class Send_to_socketio(object): + def write(self, bar): + print("should be emitting: ", bar, end="") + time.sleep(0.01) + try: + emit('from_server', {'cmd': 'model_load_status', 'data': bar.replace(" ", " ")}, broadcast=True) + except: + pass + def aria2_hook(pretrained_model_name_or_path: str, force_download=False, cache_dir=None, proxies=None, resume_download=False, local_files_only=False, use_auth_token=None, user_agent=None, revision=None, mirror=None, **kwargs): import transformers import transformers.modeling_utils @@ -268,7 +278,7 @@ def aria2_hook(pretrained_model_name_or_path: str, force_download=False, cache_d done = True break if bar is None: - bar = tqdm(total=total_length, desc=f"[aria2] Downloading model", unit="B", unit_scale=True, unit_divisor=1000) + bar = tqdm(total=total_length, desc=f"[aria2] Downloading model", unit="B", unit_scale=True, unit_divisor=1000, file=Send_to_socketio()) visited = set() for x in r: filename = x["files"][0]["path"] From 9dc9966433eede7fe9e1472ab93d0a17d848dcba Mon Sep 17 00:00:00 2001 From: scott-ca <59944183+scott-ca@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:02:03 -0600 Subject: [PATCH 09/14] Added functionality to add any/all args via json --- aiserver.py | 9 +++++++++ customsettings_template.json | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 customsettings_template.json diff --git a/aiserver.py b/aiserver.py index 9d34fe9c..87283f6a 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1044,6 +1044,7 @@ def general_startup(override_args=None): parser.add_argument("--no_aria2", action='store_true', default=False, help="Prevents KoboldAI from using aria2 to download huggingface models more efficiently, in case aria2 is causing you issues") parser.add_argument("--lowmem", action='store_true', help="Extra Low Memory loading for the GPU, slower but memory does not peak to twice the usage") parser.add_argument("--savemodel", action='store_true', help="Saves the model to the models folder even if --colab is used (Allows you to save models to Google Drive)") + parser.add_argument("--customsettings", help="Preloads arguements from json file. You only need to provide the location of the json file. Use customsettings.json template file. It can be renamed if you wish so that you can store multiple configurations. Leave any settings you want as default as null. Any values you wish to set need to be in double quotation marks") #args: argparse.Namespace = None if "pytest" in sys.modules and override_args is None: args = parser.parse_args([]) @@ -1057,6 +1058,14 @@ def general_startup(override_args=None): else: args = parser.parse_args() + if args.customsettings: + f = open (args.customsettings) + importedsettings = json.load(f) + for items in importedsettings: + if importedsettings[items] is not None: + setattr(args, items, importedsettings[items]) + f.close() + vars.model = args.model; vars.revision = args.revision diff --git a/customsettings_template.json b/customsettings_template.json new file mode 100644 index 00000000..876af058 --- /dev/null +++ b/customsettings_template.json @@ -0,0 +1,3 @@ +{"aria2_port":null, "breakmodel":null, "breakmodel_disklayers":null, "breakmodel_gpulayers":null, "breakmodel_layers":null, "colab":null, "configname":null, "cpu":null, "host":null, "localtunnel":null, "lowmem":null, "model":null, "ngrok":null, "no_aria2":null, "noaimenu":null, "nobreakmodel":null, "override_delete":null, "override_rename":null, "path":null, "port":null, "quiet":null, "remote":null, "revision":null, "savemodel":null, "unblock":null} + + From ce2efa01490e057c37917fb12d07e0f6be5121e6 Mon Sep 17 00:00:00 2001 From: scott-ca <59944183+scott-ca@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:06:56 -0600 Subject: [PATCH 10/14] Update customsettings_template.json --- customsettings_template.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/customsettings_template.json b/customsettings_template.json index 876af058..361ca4e6 100644 --- a/customsettings_template.json +++ b/customsettings_template.json @@ -1,3 +1 @@ {"aria2_port":null, "breakmodel":null, "breakmodel_disklayers":null, "breakmodel_gpulayers":null, "breakmodel_layers":null, "colab":null, "configname":null, "cpu":null, "host":null, "localtunnel":null, "lowmem":null, "model":null, "ngrok":null, "no_aria2":null, "noaimenu":null, "nobreakmodel":null, "override_delete":null, "override_rename":null, "path":null, "port":null, "quiet":null, "remote":null, "revision":null, "savemodel":null, "unblock":null} - - From 12acb50ee080b6ed0f9818e91d20324c8a049df3 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 25 Jul 2022 18:29:14 -0400 Subject: [PATCH 11/14] Fix for getting "model download status" when downloading config to figure out layer counts --- aiserver.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/aiserver.py b/aiserver.py index d7ca3841..f1cd29e6 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1312,6 +1312,7 @@ def patch_transformers_download(): def write(self, bar): bar = bar.replace("\r", "") try: + print(bar, end="\r") emit('from_server', {'cmd': 'model_load_status', 'data': bar.replace(" ", " ")}, broadcast=True) eventlet.sleep(seconds=0) except: @@ -1336,20 +1337,23 @@ def patch_transformers_download(): total = resume_size + int(content_length) if content_length is not None else None # `tqdm` behavior is determined by `utils.logging.is_progress_bar_enabled()` # and can be set using `utils.logging.enable/disable_progress_bar()` - progress = tqdm.tqdm( - unit="B", - unit_scale=True, - unit_divisor=1024, - total=total, - initial=resume_size, - desc=f"Downloading {file_name}" if file_name is not None else "Downloading", - file=Send_to_socketio(), - ) + if url[-11:] != 'config.json': + progress = tqdm.tqdm( + unit="B", + unit_scale=True, + unit_divisor=1024, + total=total, + initial=resume_size, + desc=f"Downloading {file_name}" if file_name is not None else "Downloading", + file=Send_to_socketio(), + ) for chunk in r.iter_content(chunk_size=1024): if chunk: # filter out keep-alive new chunks - progress.update(len(chunk)) + if url[-11:] != 'config.json': + progress.update(len(chunk)) temp_file.write(chunk) - progress.close() + if url[-11:] != 'config.json': + progress.close() transformers.utils.hub.http_get = http_get From 4d8a6333512b4a4d25987b348c34126cb0f65280 Mon Sep 17 00:00:00 2001 From: Henk Date: Tue, 26 Jul 2022 00:41:51 +0200 Subject: [PATCH 12/14] Aetherroom instead of aidg.club --- aiserver.py | 2 +- templates/index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/aiserver.py b/aiserver.py index ff0ea1a0..f61c5c29 100644 --- a/aiserver.py +++ b/aiserver.py @@ -5352,7 +5352,7 @@ def importgame(): def importAidgRequest(id): exitModes() - urlformat = "https://prompts.aidg.club/api/" + urlformat = "https://aetherroom.club/api/" req = requests.get(urlformat+id) if(req.status_code == 200): diff --git a/templates/index.html b/templates/index.html index 36264e7a..80481543 100644 --- a/templates/index.html +++ b/templates/index.html @@ -62,7 +62,7 @@
- (4-digit number at the end of aidg.club URL) + (4-digit number at the end of aetherroom.club URL)
From 2cf6b60c6fbc683281f60f90f1f9760eb1ee37d4 Mon Sep 17 00:00:00 2001 From: Henk Date: Tue, 26 Jul 2022 00:45:40 +0200 Subject: [PATCH 13/14] New updater backport --- install_requirements.bat | 7 +------ update-koboldai.bat | 8 ++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/install_requirements.bat b/install_requirements.bat index cd7b0aef..772c5e28 100644 --- a/install_requirements.bat +++ b/install_requirements.bat @@ -1,16 +1,11 @@ @echo off title KoboldAI Runtime Installer (MicroMamba) -echo Please choose one of the following transformers options -echo 1. Official Transformers (Recommended) -echo 2. Finetune Transformers (For old 6B models) -echo. + echo Errors? Rerun this as admin so it can add the needed LongPathsEnabled registery tweak. echo Installer failed or crashed? Run it again so it can continue. echo Only Windows 10 and higher officially supported, older Windows installations can't handle the paths. echo. -SET /P B=Type the number of the desired option and then press ENTER: - Reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d "1" /f 2>nul cd /D %~dp0 diff --git a/update-koboldai.bat b/update-koboldai.bat index 26e9ec17..5ce40985 100644 --- a/update-koboldai.bat +++ b/update-koboldai.bat @@ -1,6 +1,5 @@ @echo off -%~d0 -cd %~dp0 +cd /d %~dp0 TITLE KoboldAI - Updater SET /P M= Date: Tue, 26 Jul 2022 00:49:54 +0200 Subject: [PATCH 14/14] New spacing language --- gensettings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gensettings.py b/gensettings.py index 636b7985..3fdb7669 100644 --- a/gensettings.py +++ b/gensettings.py @@ -415,9 +415,9 @@ formatcontrols = [{ "tooltip": "Remove special characters (@,#,%,^, etc)" }, { - "label": "Add sentence spacing", + "label": "Automatic spacing", "id": "frmtadsnsp", - "tooltip": "If the last action ended with punctuation, add a space to the beginning of the next action." + "tooltip": "Add spaces automatically if needed" }, { "label": "Single Line",