mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-04-25 15:28:47 +02:00
Added saveas option for saving without metadata information
Fixed redo on an empty story erroring Fixed redo when you're at the current end of a chain causing an error
This commit is contained in:
parent
d31fb278ce
commit
2010e7b9bc
31
aiserver.py
31
aiserver.py
@ -2555,16 +2555,19 @@ def actionback():
|
|||||||
|
|
||||||
def actionredo():
|
def actionredo():
|
||||||
i = 0
|
i = 0
|
||||||
|
if len(vars.actions) < len(vars.actions_metadata):
|
||||||
|
genout = [{"generated_text": item['Text']} for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==True)]
|
||||||
|
genout = genout + [{"generated_text": item['Text']} for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Pinned"]==True) and (item["Previous Selection"]==False)]
|
||||||
|
|
||||||
genout = [{"generated_text": item['Text']} for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==True)]
|
# Store sequences in memory until selection is made
|
||||||
|
vars.genseqs = genout
|
||||||
# Store sequences in memory until selection is made
|
|
||||||
vars.genseqs = genout
|
|
||||||
|
|
||||||
|
|
||||||
# Send sequences to UI for selection
|
# Send sequences to UI for selection
|
||||||
genout = [[item['Text'], True] for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==True)]
|
genout = [[item['Text'], True] for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==True)]
|
||||||
emit('from_server', {'cmd': 'genseqs', 'data': genout}, broadcast=True)
|
emit('from_server', {'cmd': 'genseqs', 'data': genout}, broadcast=True)
|
||||||
|
else:
|
||||||
|
emit('from_server', {'cmd': 'popuperror', 'data': "There's nothing to undo"}, broadcast=True)
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
#
|
#
|
||||||
@ -2996,7 +2999,7 @@ def genselect(genout):
|
|||||||
vars.genseqs = genout
|
vars.genseqs = genout
|
||||||
|
|
||||||
genout = [[item['Text'], item['Pinned']] for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==False) and (item["Edited"]==False)]
|
genout = [[item['Text'], item['Pinned']] for item in vars.actions_metadata[len(vars.actions)]['Alternative Text'] if (item["Previous Selection"]==False) and (item["Edited"]==False)]
|
||||||
print(genout)
|
|
||||||
# Send sequences to UI for selection
|
# Send sequences to UI for selection
|
||||||
emit('from_server', {'cmd': 'genseqs', 'data': genout}, broadcast=True)
|
emit('from_server', {'cmd': 'genseqs', 'data': genout}, broadcast=True)
|
||||||
|
|
||||||
@ -3995,12 +3998,15 @@ def exitModes():
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Launch in-browser save prompt
|
# Launch in-browser save prompt
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def saveas(name):
|
def saveas(data):
|
||||||
|
|
||||||
|
name = data['name']
|
||||||
|
savepins = data['pins']
|
||||||
# Check if filename exists already
|
# Check if filename exists already
|
||||||
name = utils.cleanfilename(name)
|
name = utils.cleanfilename(name)
|
||||||
if(not fileops.saveexists(name) or (vars.saveow and vars.svowname == name)):
|
if(not fileops.saveexists(name) or (vars.saveow and vars.svowname == name)):
|
||||||
# All clear to save
|
# All clear to save
|
||||||
e = saveRequest(fileops.storypath(name))
|
e = saveRequest(fileops.storypath(name), savepins=savepins)
|
||||||
vars.saveow = False
|
vars.saveow = False
|
||||||
vars.svowname = ""
|
vars.svowname = ""
|
||||||
if(e is None):
|
if(e is None):
|
||||||
@ -4076,7 +4082,7 @@ def savetofile():
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Save the story to specified path
|
# Save the story to specified path
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def saveRequest(savpath):
|
def saveRequest(savpath, savepins=True):
|
||||||
if(savpath):
|
if(savpath):
|
||||||
# Leave Edit/Memory mode before continuing
|
# Leave Edit/Memory mode before continuing
|
||||||
exitModes()
|
exitModes()
|
||||||
@ -4092,7 +4098,8 @@ def saveRequest(savpath):
|
|||||||
js["authorsnote"] = vars.authornote
|
js["authorsnote"] = vars.authornote
|
||||||
js["anotetemplate"] = vars.authornotetemplate
|
js["anotetemplate"] = vars.authornotetemplate
|
||||||
js["actions"] = tuple(vars.actions.values())
|
js["actions"] = tuple(vars.actions.values())
|
||||||
js["actions_metadata"] = vars.actions_metadata
|
if savepins:
|
||||||
|
js["actions_metadata"] = vars.actions_metadata
|
||||||
js["worldinfo"] = []
|
js["worldinfo"] = []
|
||||||
js["wifolders_d"] = vars.wifolders_d
|
js["wifolders_d"] = vars.wifolders_d
|
||||||
js["wifolders_l"] = vars.wifolders_l
|
js["wifolders_l"] = vars.wifolders_l
|
||||||
|
@ -50,6 +50,7 @@ var aidg_accept;
|
|||||||
var aidg_close;
|
var aidg_close;
|
||||||
var saveaspopup;
|
var saveaspopup;
|
||||||
var saveasinput;
|
var saveasinput;
|
||||||
|
var savepins;
|
||||||
var topic;
|
var topic;
|
||||||
var saveas_accept;
|
var saveas_accept;
|
||||||
var saveas_close;
|
var saveas_close;
|
||||||
@ -749,7 +750,7 @@ function enterMemoryMode() {
|
|||||||
setchatnamevisibility(false);
|
setchatnamevisibility(false);
|
||||||
showMessage("Edit the memory to be sent with each request to the AI.");
|
showMessage("Edit the memory to be sent with each request to the AI.");
|
||||||
button_actmem.html("Cancel");
|
button_actmem.html("Cancel");
|
||||||
hide([button_actback, button_actretry, button_actwi]);
|
hide([button_actback, button_actfwd, button_actretry, button_actwi]);
|
||||||
// Display Author's Note field
|
// Display Author's Note field
|
||||||
anote_menu.slideDown("fast");
|
anote_menu.slideDown("fast");
|
||||||
}
|
}
|
||||||
@ -760,7 +761,7 @@ function exitMemoryMode() {
|
|||||||
setchatnamevisibility(chatmode);
|
setchatnamevisibility(chatmode);
|
||||||
hideMessage();
|
hideMessage();
|
||||||
button_actmem.html("Memory");
|
button_actmem.html("Memory");
|
||||||
show([button_actback, button_actretry, button_actwi]);
|
show([button_actback, button_actfwd, button_actretry, button_actwi]);
|
||||||
input_text.val("");
|
input_text.val("");
|
||||||
// Hide Author's Note field
|
// Hide Author's Note field
|
||||||
anote_menu.slideUp("fast");
|
anote_menu.slideUp("fast");
|
||||||
@ -769,7 +770,7 @@ function exitMemoryMode() {
|
|||||||
function enterWiMode() {
|
function enterWiMode() {
|
||||||
showMessage("World Info will be added to memory only when the key appears in submitted text or the last action.");
|
showMessage("World Info will be added to memory only when the key appears in submitted text or the last action.");
|
||||||
button_actwi.html("Accept");
|
button_actwi.html("Accept");
|
||||||
hide([button_actback, button_actmem, button_actretry, game_text]);
|
hide([button_actback, button_actfwd, button_actmem, button_actretry, game_text]);
|
||||||
setchatnamevisibility(false);
|
setchatnamevisibility(false);
|
||||||
show([wi_menu]);
|
show([wi_menu]);
|
||||||
disableSendBtn();
|
disableSendBtn();
|
||||||
@ -781,7 +782,7 @@ function exitWiMode() {
|
|||||||
button_actwi.html("W Info");
|
button_actwi.html("W Info");
|
||||||
hide([wi_menu]);
|
hide([wi_menu]);
|
||||||
setchatnamevisibility(chatmode);
|
setchatnamevisibility(chatmode);
|
||||||
show([button_actback, button_actmem, button_actretry, game_text]);
|
show([button_actback, button_actfwd, button_actmem, button_actretry, game_text]);
|
||||||
enableSendBtn();
|
enableSendBtn();
|
||||||
$("#gamescreen").removeClass("wigamescreen");
|
$("#gamescreen").removeClass("wigamescreen");
|
||||||
}
|
}
|
||||||
@ -885,7 +886,7 @@ function hideSaveAsPopup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendSaveAsRequest() {
|
function sendSaveAsRequest() {
|
||||||
socket.send({'cmd': 'saveasrequest', 'data': saveasinput.val()});
|
socket.send({'cmd': 'saveasrequest', 'data': {"name": saveasinput.val(), "pins": savepins.val()});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoadPopup() {
|
function showLoadPopup() {
|
||||||
@ -1143,9 +1144,9 @@ function updateSPStatItems(items) {
|
|||||||
function setStartState() {
|
function setStartState() {
|
||||||
enableSendBtn();
|
enableSendBtn();
|
||||||
enableButtons([button_actmem, button_actwi]);
|
enableButtons([button_actmem, button_actwi]);
|
||||||
disableButtons([button_actback, button_actretry]);
|
disableButtons([button_actback, button_actfwd, button_actretry]);
|
||||||
hide([wi_menu]);
|
hide([wi_menu]);
|
||||||
show([game_text, button_actmem, button_actwi, button_actback, button_actretry]);
|
show([game_text, button_actmem, button_actwi, button_actback, button_actfwd, button_actretry]);
|
||||||
hideMessage();
|
hideMessage();
|
||||||
hideWaitAnimation();
|
hideWaitAnimation();
|
||||||
button_actmem.html("Memory");
|
button_actmem.html("Memory");
|
||||||
@ -1784,6 +1785,7 @@ $(document).ready(function(){
|
|||||||
aidg_close = $("#btn_aidgpopupclose");
|
aidg_close = $("#btn_aidgpopupclose");
|
||||||
saveaspopup = $("#saveascontainer");
|
saveaspopup = $("#saveascontainer");
|
||||||
saveasinput = $("#savename");
|
saveasinput = $("#savename");
|
||||||
|
savepins = $("#savepins");
|
||||||
topic = $("#topic");
|
topic = $("#topic");
|
||||||
saveas_accept = $("#btn_saveasaccept");
|
saveas_accept = $("#btn_saveasaccept");
|
||||||
saveas_close = $("#btn_saveasclose");
|
saveas_close = $("#btn_saveasclose");
|
||||||
@ -1932,13 +1934,13 @@ $(document).ready(function(){
|
|||||||
// Enable or Disable buttons
|
// Enable or Disable buttons
|
||||||
if(msg.data == "ready") {
|
if(msg.data == "ready") {
|
||||||
enableSendBtn();
|
enableSendBtn();
|
||||||
enableButtons([button_actmem, button_actwi, button_actback, button_actretry]);
|
enableButtons([button_actmem, button_actwi, button_actback, button_actfwd, button_actretry]);
|
||||||
hideWaitAnimation();
|
hideWaitAnimation();
|
||||||
gamestate = "ready";
|
gamestate = "ready";
|
||||||
} else if(msg.data == "wait") {
|
} else if(msg.data == "wait") {
|
||||||
gamestate = "wait";
|
gamestate = "wait";
|
||||||
disableSendBtn();
|
disableSendBtn();
|
||||||
disableButtons([button_actmem, button_actwi, button_actback, button_actretry]);
|
disableButtons([button_actmem, button_actwi, button_actback, button_actfwd, button_actretry]);
|
||||||
showWaitAnimation();
|
showWaitAnimation();
|
||||||
} else if(msg.data == "start") {
|
} else if(msg.data == "start") {
|
||||||
setStartState();
|
setStartState();
|
||||||
|
@ -229,7 +229,9 @@
|
|||||||
<div class="popuptitletext">Enter Name For Save</div>
|
<div class="popuptitletext">Enter Name For Save</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="aidgpopupcontent">
|
<div class="aidgpopupcontent">
|
||||||
<input class="form-control" type="text" placeholder="Save Name" id="savename">
|
<input class="form-control" type="text" placeholder="Save Name" id="savename"><br>
|
||||||
|
<input type="checkbox" data-toggle="toggle" data-onstyle="success" id="savepins" checked>
|
||||||
|
<div class="box-label">Save Pin Information</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="popuperror hidden">
|
<div class="popuperror hidden">
|
||||||
<span></span>
|
<span></span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user