From 6d9063fb8b13d29e560114cbadbe4b9145317bbb Mon Sep 17 00:00:00 2001 From: henk717 Date: Thu, 16 Dec 2021 12:47:44 +0100 Subject: [PATCH] No Prompt Gen Allow people to enter a prompt without generating anything by the AI. Combined with the always add prompt this is a very useful feature that allows people to write world information first, and then do a specific action. This mimics the behavior previously seen in AI Dungeon forks where it prompts for world information and then asks an action and can be particularly useful for people who want the prompt to always be part of the generation. --- aiserver.py | 14 +++++++++++++- gensettings.py | 11 +++++++++++ static/application.js | 3 +++ templates/index.html | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/aiserver.py b/aiserver.py index 79ff25b9..5b70b10d 100644 --- a/aiserver.py +++ b/aiserver.py @@ -161,6 +161,7 @@ class vars: adventure = False dynamicscan = False remote = False + nopromptgen = False #==================================================================# # Function to get model selection at startup @@ -1172,6 +1173,7 @@ def lua_has_setting(setting): "setuseprompt", "setadventure", "setdynamicscan", + "nopromptgen", "frmttriminc", "frmtrmblln", "frmtrmspch", @@ -1194,6 +1196,7 @@ def lua_get_setting(setting): if(setting == "setuseprompt"): return vars.useprompt if(setting == "setadventure"): return vars.adventure if(setting == "setdynamicscan"): return vars.dynamicscan + if(setting == "nopromptgen"): return vars.nopromptgen if(setting == "frmttriminc"): return vars.formatoptns["frmttriminc"] if(setting == "frmtrmblln"): return vars.formatoptns["frmttriminc"] if(setting == "frmtrmspch"): return vars.formatoptns["frmttriminc"] @@ -1221,6 +1224,7 @@ def lua_set_setting(setting, v): if(setting == "setuseprompt"): vars.useprompt = v if(setting == "setadventure"): vars.adventure = v if(setting == "setdynamicscan"): vars.dynamicscan = v + if(setting == "setnopromptgen"): vars.nopromptgen = v if(setting == "frmttriminc"): vars.formatoptns["frmttriminc"] = v if(setting == "frmtrmblln"): vars.formatoptns["frmttriminc"] = v if(setting == "frmtrmspch"): vars.formatoptns["frmttriminc"] = v @@ -1692,6 +1696,10 @@ def get_message(msg): vars.dynamicscan = msg['data'] settingschanged() refresh_settings() + elif(msg['cmd'] == 'setnopromptgen'): + vars.nopromptgen = msg['data'] + settingschanged() + refresh_settings() elif(not vars.remote and msg['cmd'] == 'importwi'): wiimportrequest() @@ -1748,6 +1756,7 @@ def savesettings(): js["useprompt"] = vars.useprompt js["adventure"] = vars.adventure js["dynamicscan"] = vars.dynamicscan + js["nopromptgen"] = vars.nopromptgen js["userscripts"] = vars.userscripts js["corescript"] = vars.corescript @@ -1803,6 +1812,8 @@ def loadsettings(): vars.adventure = js["adventure"] if("dynamicscan" in js): vars.dynamicscan = js["dynamicscan"] + if("nopromptgen" in js): + vars.nopromptgen = js["nopromptgen"] if("userscripts" in js): vars.userscripts = [] @@ -1887,7 +1898,7 @@ def actionsubmit(data, actionmode=0, force_submit=False): assert False # Start the game vars.gamestarted = True - if(not vars.noai and vars.lua_koboldbridge.generating): + if(not vars.noai and vars.lua_koboldbridge.generating and not vars.nopromptgen): # Save this first action as the prompt vars.prompt = data # Clear the startup text from game screen @@ -2671,6 +2682,7 @@ def refresh_settings(): emit('from_server', {'cmd': 'updateuseprompt', 'data': vars.useprompt}, broadcast=True) emit('from_server', {'cmd': 'updateadventure', 'data': vars.adventure}, broadcast=True) emit('from_server', {'cmd': 'updatedynamicscan', 'data': vars.dynamicscan}, broadcast=True) + emit('from_server', {'cmd': 'updatenopromptgen', 'data': vars.nopromptgen}, broadcast=True) emit('from_server', {'cmd': 'updatefrmttriminc', 'data': vars.formatoptns["frmttriminc"]}, broadcast=True) emit('from_server', {'cmd': 'updatefrmtrmblln', 'data': vars.formatoptns["frmtrmblln"]}, broadcast=True) diff --git a/gensettings.py b/gensettings.py index 1d735266..62299475 100644 --- a/gensettings.py +++ b/gensettings.py @@ -129,6 +129,17 @@ gensettingstf = [{ "step": 1, "default": 0, "tooltip": "Scan the AI's output for world info keys as it's generating the output." + }, + { + "uitype": "toggle", + "unit": "bool", + "label": "No Prompt Generation", + "id": "setnopromptgen", + "min": 0, + "max": 1, + "step": 1, + "default": 0, + "tooltip": "When enabled the AI does not generate when you enter the prompt, instead you need to do an action first." }] gensettingsik =[{ diff --git a/static/application.js b/static/application.js index e23dffc4..d4fcfe4f 100644 --- a/static/application.js +++ b/static/application.js @@ -2016,6 +2016,9 @@ $(document).ready(function(){ } else if(msg.cmd == "updatedynamicscan") { // Update toggle state $("#setdynamicscan").prop('checked', msg.data).change(); + } else if(msg.cmd == "updatenopromptgen") { + // Update toggle state + $("#setnopromptgen").prop('checked', msg.data).change(); } else if(msg.cmd == "runs_remotely") { remote = true; hide([button_savetofile, button_import, button_importwi]); diff --git a/templates/index.html b/templates/index.html index 08980ef3..a394d854 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,7 +7,7 @@ - +