mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 20:20:45 +01:00
commit
245ff6d2f3
40
aiserver.py
40
aiserver.py
@ -1,6 +1,6 @@
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
# KoboldAI
|
# KoboldAI
|
||||||
# Version: 1.16.1
|
# Version: 1.16.2
|
||||||
# By: KoboldAIDev and the KoboldAI Community
|
# By: KoboldAIDev and the KoboldAI Community
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
|
||||||
@ -930,7 +930,7 @@ def settingschanged():
|
|||||||
#==================================================================#
|
#==================================================================#
|
||||||
# Take input text from SocketIO and decide what to do with it
|
# Take input text from SocketIO and decide what to do with it
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def actionsubmit(data, actionmode=0):
|
def actionsubmit(data, actionmode=0, force_submit=False):
|
||||||
# Ignore new submissions if the AI is currently busy
|
# Ignore new submissions if the AI is currently busy
|
||||||
if(vars.aibusy):
|
if(vars.aibusy):
|
||||||
return
|
return
|
||||||
@ -944,13 +944,17 @@ def actionsubmit(data, actionmode=0):
|
|||||||
if(actionmode == 1):
|
if(actionmode == 1):
|
||||||
data = data.strip().lstrip('>')
|
data = data.strip().lstrip('>')
|
||||||
data = re.sub(r'\n+', ' ', data)
|
data = re.sub(r'\n+', ' ', data)
|
||||||
data = f"\n\n> {data}\n"
|
if(len(data)):
|
||||||
|
data = f"\n\n> {data}\n"
|
||||||
|
|
||||||
# If we're not continuing, store a copy of the raw input
|
# If we're not continuing, store a copy of the raw input
|
||||||
if(data != ""):
|
if(data != ""):
|
||||||
vars.lastact = data
|
vars.lastact = data
|
||||||
|
|
||||||
if(not vars.gamestarted):
|
if(not vars.gamestarted):
|
||||||
|
if(not force_submit and len(data.strip()) == 0):
|
||||||
|
set_aibusy(0)
|
||||||
|
return
|
||||||
# Start the game
|
# Start the game
|
||||||
vars.gamestarted = True
|
vars.gamestarted = True
|
||||||
# Save this first action as the prompt
|
# Save this first action as the prompt
|
||||||
@ -971,7 +975,10 @@ def actionsubmit(data, actionmode=0):
|
|||||||
if(vars.actionmode == 0):
|
if(vars.actionmode == 0):
|
||||||
data = applyinputformatting(data)
|
data = applyinputformatting(data)
|
||||||
# Store the result in the Action log
|
# Store the result in the Action log
|
||||||
vars.actions.append(data)
|
if(len(vars.prompt.strip()) == 0):
|
||||||
|
vars.prompt = data
|
||||||
|
else:
|
||||||
|
vars.actions.append(data)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
|
|
||||||
if(not vars.noai):
|
if(not vars.noai):
|
||||||
@ -994,12 +1001,13 @@ def actionretry(data):
|
|||||||
# Remove last action if possible and resubmit
|
# Remove last action if possible and resubmit
|
||||||
if(vars.gamestarted if vars.useprompt else len(vars.actions) > 0):
|
if(vars.gamestarted if vars.useprompt else len(vars.actions) > 0):
|
||||||
set_aibusy(1)
|
set_aibusy(1)
|
||||||
if(not vars.recentback and not vars.recentedit and len(vars.actions) != 0 and len(vars.genseqs) == 0): # Don't pop if we're in the "Select sequence to keep" menu or if there are no non-prompt actions
|
if(not vars.recentback and len(vars.actions) != 0 and len(vars.genseqs) == 0): # Don't pop if we're in the "Select sequence to keep" menu or if there are no non-prompt actions
|
||||||
last_key = vars.actions.get_last_key()
|
last_key = vars.actions.get_last_key()
|
||||||
vars.actions.pop()
|
vars.actions.pop()
|
||||||
remove_story_chunk(last_key + 1)
|
remove_story_chunk(last_key + 1)
|
||||||
vars.genseqs = []
|
vars.genseqs = []
|
||||||
calcsubmit('')
|
calcsubmit('')
|
||||||
|
emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True)
|
||||||
vars.recentback = False
|
vars.recentback = False
|
||||||
vars.recentedit = False
|
vars.recentedit = False
|
||||||
elif(not vars.useprompt):
|
elif(not vars.useprompt):
|
||||||
@ -1284,7 +1292,10 @@ def genresult(genout):
|
|||||||
genout = applyoutputformatting(genout)
|
genout = applyoutputformatting(genout)
|
||||||
|
|
||||||
# Add formatted text to Actions array and refresh the game screen
|
# Add formatted text to Actions array and refresh the game screen
|
||||||
vars.actions.append(genout)
|
if(len(vars.prompt.strip()) == 0):
|
||||||
|
vars.prompt = genout
|
||||||
|
else:
|
||||||
|
vars.actions.append(genout)
|
||||||
update_story_chunk('last')
|
update_story_chunk('last')
|
||||||
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
emit('from_server', {'cmd': 'texteffect', 'data': vars.actions.get_last_key() if len(vars.actions) else 0}, broadcast=True)
|
||||||
|
|
||||||
@ -2102,8 +2113,19 @@ def loadRequest(loadpath):
|
|||||||
|
|
||||||
del vars.actions
|
del vars.actions
|
||||||
vars.actions = structures.KoboldStoryRegister()
|
vars.actions = structures.KoboldStoryRegister()
|
||||||
for s in js["actions"]:
|
actions = collections.deque(js["actions"])
|
||||||
vars.actions.append(s)
|
|
||||||
|
if(len(vars.prompt.strip()) == 0):
|
||||||
|
while(len(actions)):
|
||||||
|
action = actions.popleft()
|
||||||
|
if(len(action.strip()) != 0):
|
||||||
|
vars.prompt = action
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
vars.gamestarted = False
|
||||||
|
if(vars.gamestarted):
|
||||||
|
for s in actions:
|
||||||
|
vars.actions.append(s)
|
||||||
|
|
||||||
# Try not to break older save files
|
# Try not to break older save files
|
||||||
if("authorsnote" in js):
|
if("authorsnote" in js):
|
||||||
@ -2377,7 +2399,7 @@ def newGameRequest():
|
|||||||
def randomGameRequest(topic):
|
def randomGameRequest(topic):
|
||||||
newGameRequest()
|
newGameRequest()
|
||||||
vars.memory = "You generate the following " + topic + " story concept :"
|
vars.memory = "You generate the following " + topic + " story concept :"
|
||||||
actionsubmit("")
|
actionsubmit("", force_submit=True)
|
||||||
vars.memory = ""
|
vars.memory = ""
|
||||||
|
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
|
@ -466,6 +466,7 @@ function enterWiMode() {
|
|||||||
hide([button_actback, button_actmem, button_actretry, game_text]);
|
hide([button_actback, button_actmem, button_actretry, game_text]);
|
||||||
show([wi_menu]);
|
show([wi_menu]);
|
||||||
disableSendBtn();
|
disableSendBtn();
|
||||||
|
$("#gamescreen").addClass("wigamescreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
function exitWiMode() {
|
function exitWiMode() {
|
||||||
@ -474,7 +475,7 @@ function exitWiMode() {
|
|||||||
hide([wi_menu]);
|
hide([wi_menu]);
|
||||||
show([button_actback, button_actmem, button_actretry, game_text]);
|
show([button_actback, button_actmem, button_actretry, game_text]);
|
||||||
enableSendBtn();
|
enableSendBtn();
|
||||||
scrollToBottom();
|
$("#gamescreen").removeClass("wigamescreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
function returnWiList(ar) {
|
function returnWiList(ar) {
|
||||||
@ -493,7 +494,11 @@ function returnWiList(ar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dosubmit() {
|
function dosubmit() {
|
||||||
var txt = input_text.val();
|
var txt = input_text.val().replace(/\u00a0/g, " ");
|
||||||
|
console.log(gamestarted)
|
||||||
|
if(!gamestarted && ((!adventure || !action_mode) && txt.trim().length == 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'data': txt});
|
socket.send({'cmd': 'submit', 'actionmode': adventure ? action_mode : 0, 'data': txt});
|
||||||
if(memorymode) {
|
if(memorymode) {
|
||||||
memorytext = input_text.val();
|
memorytext = input_text.val();
|
||||||
@ -881,7 +886,7 @@ function syncAllModifiedChunks(including_selected_chunks=false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function restorePrompt() {
|
function restorePrompt() {
|
||||||
if(game_text[0].firstChild.nodeType === 3) {
|
if(game_text[0].firstChild && game_text[0].firstChild.nodeType === 3) {
|
||||||
saved_prompt = game_text[0].firstChild.textContent.replace(/\u00a0/g, " ");
|
saved_prompt = game_text[0].firstChild.textContent.replace(/\u00a0/g, " ");
|
||||||
unbindGametext();
|
unbindGametext();
|
||||||
game_text[0].innerText = "";
|
game_text[0].innerText = "";
|
||||||
|
@ -77,6 +77,11 @@ chunk.editing, chunk.editing * {
|
|||||||
font-family: "Helvetica";
|
font-family: "Helvetica";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gamescreen.wigamescreen {
|
||||||
|
padding: 10px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
#gamescreen span {
|
#gamescreen span {
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<script src="static/jquery-3.6.0.min.js"></script>
|
<script src="static/jquery-3.6.0.min.js"></script>
|
||||||
<script src="static/socket.io.min.js"></script>
|
<script src="static/socket.io.min.js"></script>
|
||||||
<script src="static/application.js?ver=0.15.0g"></script>
|
<script src="static/application.js?ver=1.16.2a"></script>
|
||||||
<script src="static/bootstrap.min.js"></script>
|
<script src="static/bootstrap.min.js"></script>
|
||||||
<script src="static/bootstrap-toggle.min.js"></script>
|
<script src="static/bootstrap-toggle.min.js"></script>
|
||||||
<script src="static/rangy-core.min.js"></script>
|
<script src="static/rangy-core.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="static/bootstrap.min.css">
|
<link rel="stylesheet" href="static/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="static/bootstrap-toggle.min.css">
|
<link rel="stylesheet" href="static/bootstrap-toggle.min.css">
|
||||||
<link rel="stylesheet" href="static/custom.css?ver=0.15.0g">
|
<link rel="stylesheet" href="static/custom.css?ver=1.16.2a">
|
||||||
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
|
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user