Add Memory box to Random Story dialog and "Random Story Persist"

This commit is contained in:
Gnome Ann 2021-12-29 23:15:59 -05:00
parent 756a7941f2
commit 7573f64bf2
6 changed files with 99 additions and 14 deletions

View File

@ -179,6 +179,7 @@ class vars:
dynamicscan = False
remote = False
nopromptgen = False
rngpersist = False
#==================================================================#
# Function to get model selection at startup
@ -1263,9 +1264,12 @@ def lua_has_setting(setting):
"setchatmode",
"setdynamicscan",
"setnopromptgen",
"setrngpersist",
"temp",
"topp",
"top_p",
"topk",
"top_k",
"tfs",
"reppen",
"tknmax",
@ -1276,6 +1280,7 @@ def lua_has_setting(setting):
"adventure",
"dynamicscan",
"nopromptgen",
"rngpersist",
"frmttriminc",
"frmtrmblln",
"frmtrmspch",
@ -1293,8 +1298,8 @@ def lua_has_setting(setting):
#==================================================================#
def lua_get_setting(setting):
if(setting in ("settemp", "temp")): return vars.temp
if(setting in ("settopp", "topp")): return vars.top_p
if(setting in ("settopk", "topk")): return vars.top_k
if(setting in ("settopp", "topp", "top_p")): return vars.top_p
if(setting in ("settopk", "topk", "top_k")): return vars.top_k
if(setting in ("settfs", "tfs")): return vars.tfs
if(setting in ("setreppen", "reppen")): return vars.rep_pen
if(setting in ("settknmax", "tknmax")): return vars.max_length
@ -1305,6 +1310,7 @@ def lua_get_setting(setting):
if(setting in ("setchatmode", "chatmode")): return vars.chatmode
if(setting in ("setdynamicscan", "dynamicscan")): return vars.dynamicscan
if(setting in ("setnopromptgen", "nopromptgen")): return vars.nopromptgen
if(setting in ("setrngpersist", "rngpersist")): return vars.rngpersist
if(setting in ("frmttriminc", "triminc")): return vars.formatoptns["frmttriminc"]
if(setting in ("frmtrmblln", "rmblln")): return vars.formatoptns["frmttrmblln"]
if(setting in ("frmtrmspch", "rmspch")): return vars.formatoptns["frmttrmspch"]
@ -1333,6 +1339,7 @@ def lua_set_setting(setting, v):
if(setting in ("setadventure", "adventure")): vars.adventure = v
if(setting in ("setdynamicscan", "dynamicscan")): vars.dynamicscan = v
if(setting in ("setnopromptgen", "nopromptgen")): vars.nopromptgen = v
if(setting in ("setrngpersist", "rngpersist")): vars.rngpersist = v
if(setting in ("setchatmode", "chatmode")): vars.chatmode = v
if(setting in ("frmttriminc", "triminc")): vars.formatoptns["frmttriminc"] = v
if(setting in ("frmtrmblln", "rmblln")): vars.formatoptns["frmttrmblln"] = v
@ -1667,7 +1674,7 @@ def get_message(msg):
elif(msg['cmd'] == 'newgame'):
newGameRequest()
elif(msg['cmd'] == 'rndgame'):
randomGameRequest(msg['data'])
randomGameRequest(msg['data'], memory=msg['memory'])
elif(msg['cmd'] == 'settemp'):
vars.temp = float(msg['data'])
emit('from_server', {'cmd': 'setlabeltemp', 'data': msg['data']}, broadcast=True)
@ -1883,6 +1890,10 @@ def get_message(msg):
vars.nopromptgen = msg['data']
settingschanged()
refresh_settings()
elif(msg['cmd'] == 'setrngpersist'):
vars.rngpersist = msg['data']
settingschanged()
refresh_settings()
elif(not vars.remote and msg['cmd'] == 'importwi'):
wiimportrequest()
@ -1952,6 +1963,7 @@ def savesettings():
js["chatname"] = vars.chatname
js["dynamicscan"] = vars.dynamicscan
js["nopromptgen"] = vars.nopromptgen
js["rngpersist"] = vars.rngpersist
js["userscripts"] = vars.userscripts
js["corescript"] = vars.corescript
@ -2014,6 +2026,8 @@ def loadsettings():
vars.dynamicscan = js["dynamicscan"]
if("nopromptgen" in js):
vars.nopromptgen = js["nopromptgen"]
if("rngpersist" in js):
vars.rngpersist = js["rngpersist"]
if("userscripts" in js):
vars.userscripts = []
@ -2992,6 +3006,7 @@ def refresh_settings():
emit('from_server', {'cmd': 'updatechatmode', 'data': vars.chatmode}, 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': 'updaterngpersist', 'data': vars.rngpersist}, broadcast=True)
emit('from_server', {'cmd': 'updatefrmttriminc', 'data': vars.formatoptns["frmttriminc"]}, broadcast=True)
emit('from_server', {'cmd': 'updatefrmtrmblln', 'data': vars.formatoptns["frmtrmblln"]}, broadcast=True)
@ -4184,23 +4199,28 @@ def newGameRequest():
emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True)
setStartState()
def randomGameRequest(topic):
def randomGameRequest(topic, memory=""):
if(vars.noai):
newGameRequest()
return
vars.recentrng = topic
newGameRequest()
vars.memory = "You generate the following " + topic + " story concept :"
if(len(memory) > 0):
memory = memory.rstrip() + "\n\n"
vars.memory = memory + "You generate the following " + topic + " story concept :"
vars.lua_koboldbridge.feedback = None
actionsubmit("", force_submit=True, force_prompt_gen=True)
vars.memory = ""
vars.memory = memory
# Load settings from client.settings
loadmodelsettings()
loadsettings()
#==================================================================#
# Final startup commands to launch Flask app
#==================================================================#
if __name__ == "__main__":
# Load settings from client.settings
loadmodelsettings()
loadsettings()
# Start Flask/SocketIO (Blocking, so this must be last method!)
#socketio.run(app, host='0.0.0.0', port=5000)

View File

@ -867,9 +867,12 @@ return function(_python, _bridged)
---@field setadventure boolean
---@field setdynamicscan boolean
---@field setnopromptgen boolean
---@field setrngpersist boolean
---@field temp number
---@field topp number
---@field topk integer
---@field top_p number
---@field top_k integer
---@field tfs number
---@field reppen number
---@field tknmax integer
@ -878,6 +881,7 @@ return function(_python, _bridged)
---@field adventure boolean
---@field dynamicscan boolean
---@field nopromptgen boolean
---@field rngpersist boolean
---@field frmttriminc boolean
---@field frmtrmblln boolean
---@field frmtrmspch boolean

View File

@ -151,6 +151,17 @@ gensettingstf = [{
"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."
},
{
"uitype": "toggle",
"unit": "bool",
"label": "Random Story Persist",
"id": "setrngpersist",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "When enabled, the Memory text box in the Random Story dialog will be prefilled by default with your current story's memory instead of being empty."
}]
gensettingsik =[{
@ -251,6 +262,28 @@ gensettingsik =[{
"step": 1,
"default": 0,
"tooltip": "Turn this on if you are playing a Choose your Adventure model."
},
{
"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."
},
{
"uitype": "toggle",
"unit": "bool",
"label": "Random Story Persist",
"id": "setrngpersist",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "When enabled, the Memory text box in the Random Story dialog will be prefilled by default with your current story's memory instead of being empty."
}]
formatcontrols = [{

View File

@ -1054,6 +1054,9 @@ function hideNewStoryPopup() {
function showRandomStoryPopup() {
rspopup.removeClass("hidden");
rspopup.addClass("flex");
if($("#setrngpersist").prop("checked")) {
$("#rngmemory").val(memorytext);
}
}
function hideRandomStoryPopup() {
@ -2180,6 +2183,12 @@ $(document).ready(function(){
} else if(msg.cmd == "updatenopromptgen") {
// Update toggle state
$("#setnopromptgen").prop('checked', msg.data).change();
} else if(msg.cmd == "updaterngpersist") {
// Update toggle state
$("#setrngpersist").prop('checked', msg.data).change();
if(!$("#setrngpersist").prop("checked")) {
$("#rngmemory").val("");
}
} else if(msg.cmd == "runs_remotely") {
remote = true;
hide([button_savetofile, button_import, button_importwi]);
@ -2435,7 +2444,7 @@ $(document).ready(function(){
rs_accept.on("click", function(ev) {
hideMessage();
socket.send({'cmd': 'rndgame', 'data': topic.val()});
socket.send({'cmd': 'rndgame', 'memory': $("#rngmemory").val(), 'data': topic.val()});
hideRandomStoryPopup();
});

View File

@ -32,6 +32,22 @@ chunk.editing, chunk.editing * {
display: flex;
}
#topic {
margin-top: 20px;
resize: none;
overflow: auto;
background-color: #404040;
color: #ffffff;
}
#rngmemory {
height: 80px;
resize: none;
overflow:auto;
background-color: #404040;
color: #ffffff;
}
#chatname {
background-color: #404040;
color: #ffffff;
@ -387,7 +403,7 @@ chunk.editing, chunk.editing * {
#rspopup {
width: 800px;
background-color: #262626;
margin-top: 200px;
margin-top: 150px;
}
/*================= Classes =================*/

View File

@ -10,12 +10,12 @@
<script src="static/bootstrap.min.js"></script>
<script src="static/bootstrap-toggle.min.js"></script>
<script src="static/rangy-core.min.js"></script>
<script src="static/application.js?ver=1.16.4n"></script>
<script src="static/application.js?ver=1.16.4o"></script>
<link rel="stylesheet" href="static/jquery-ui.sortable.min.css">
<link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/bootstrap-toggle.min.css">
<link rel="stylesheet" href="static/custom.css?ver=1.16.4h">
<link rel="stylesheet" href="static/custom.css?ver=1.16.4i">
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
</head>
<body>
@ -353,6 +353,9 @@
<div class="aidgpopupcontent">
<input class="form-control" type="text" placeholder="Story Genre Suggestion (Leave blank for fully random)" id="topic">
</div>
<div class="aidgpopupcontent">
<textarea class="form-control" placeholder="Memory" id="rngmemory"></textarea>
</div>
<div class="popupfooter">
<button type="button" class="btn btn-primary" id="btn_rsaccept">Accept</button>
<button type="button" class="btn btn-primary" id="btn_rsclose">Cancel</button>