From 769333738da17ee408b19e0d7a8b96c71e1a9d55 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Fri, 17 Dec 2021 12:59:01 -0500 Subject: [PATCH 1/2] Fix behaviour of `kobold.outputs` with read-only and no prompt gen --- aiserver.py | 4 ++++ bridge.lua | 1 + 2 files changed, 5 insertions(+) diff --git a/aiserver.py b/aiserver.py index 5b70b10d..e1db156e 100644 --- a/aiserver.py +++ b/aiserver.py @@ -1908,6 +1908,8 @@ def actionsubmit(data, actionmode=0, force_submit=False): else: # Save this first action as the prompt vars.prompt = data + for i in range(vars.numseqs): + vars.lua_koboldbridge.outputs[i+1] = "" execute_outmod() if(vars.lua_koboldbridge.regeneration_required): vars.lua_koboldbridge.regeneration_required = False @@ -1943,6 +1945,8 @@ def actionsubmit(data, actionmode=0, force_submit=False): calcsubmit(data) emit('from_server', {'cmd': 'scrolldown', 'data': ''}, broadcast=True) else: + for i in range(vars.numseqs): + vars.lua_koboldbridge.outputs[i+1] = "" execute_outmod() set_aibusy(0) if(vars.lua_koboldbridge.regeneration_required): diff --git a/bridge.lua b/bridge.lua index 087c24c5..77178916 100644 --- a/bridge.lua +++ b/bridge.lua @@ -1671,6 +1671,7 @@ return function(_python, _bridged) setmetatable(koboldbridge.outputs, nil) for k, v in old_next, koboldbridge.outputs, nil do if type(v) ~= "string" then + error("`kobold.outputs` must be a 1D list of strings, but found a non-string element at index " .. k) return r end if v ~= _outputs[k] then From 12718dbe24a1ec5ef4cfb6e226395c3babd4c6f9 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Fri, 17 Dec 2021 13:18:47 -0500 Subject: [PATCH 2/2] Try long-polling first, then try websocket This makes it so that SocketIO uses long polling to set up the connection before switching to websocket, instead of immediately using websocket. This seems to resolve issues where the browser sometimes can't connect to the websocket server until the window has been open for a minute. --- static/application.js | 2 +- templates/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/application.js b/static/application.js index d4fcfe4f..dc289a73 100644 --- a/static/application.js +++ b/static/application.js @@ -1619,7 +1619,7 @@ $(document).ready(function(){ seqselcontents = $("#seqselcontents"); // Connect to SocketIO server - socket = io.connect(window.document.origin, {transports: ['websocket', 'polling']}); + socket = io.connect(window.document.origin, {transports: ['polling', 'websocket']}); socket.on('from_server', function(msg) { if(msg.cmd == "connected") { diff --git a/templates/index.html b/templates/index.html index a394d854..dcd31bfe 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,7 +7,7 @@ - +