Merge 'nolialsea/patch-1' into settings without Colab changes
This commit is contained in:
commit
c7b03398f6
18
aiserver.py
18
aiserver.py
|
@ -779,6 +779,7 @@ parser = argparse.ArgumentParser(description="KoboldAI Server")
|
||||||
parser.add_argument("--remote", action='store_true', help="Optimizes KoboldAI for Remote Play")
|
parser.add_argument("--remote", action='store_true', help="Optimizes KoboldAI for Remote Play")
|
||||||
parser.add_argument("--ngrok", action='store_true', help="Optimizes KoboldAI for Remote Play using Ngrok")
|
parser.add_argument("--ngrok", action='store_true', help="Optimizes KoboldAI for Remote Play using Ngrok")
|
||||||
parser.add_argument("--host", action='store_true', help="Optimizes KoboldAI for Remote Play without using a proxy service")
|
parser.add_argument("--host", action='store_true', help="Optimizes KoboldAI for Remote Play without using a proxy service")
|
||||||
|
parser.add_argument("--port", type=int, help="Specify the port on which the application will be joinable")
|
||||||
parser.add_argument("--model", help="Specify the Model Type to skip the Menu")
|
parser.add_argument("--model", help="Specify the Model Type to skip the Menu")
|
||||||
parser.add_argument("--path", help="Specify the Path for local models (For model NeoCustom or GPT2Custom)")
|
parser.add_argument("--path", help="Specify the Path for local models (For model NeoCustom or GPT2Custom)")
|
||||||
parser.add_argument("--cpu", action='store_true', help="By default unattended launches are on the GPU use this option to force CPU usage.")
|
parser.add_argument("--cpu", action='store_true', help="By default unattended launches are on the GPU use this option to force CPU usage.")
|
||||||
|
@ -5321,6 +5322,7 @@ def send_debug():
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
print("", end="", flush=True)
|
print("", end="", flush=True)
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
port = args.port if "port" in args and args.port is not None else 5000
|
||||||
print("{0}\nStarting webserver...{1}".format(colors.GREEN, colors.END), flush=True)
|
print("{0}\nStarting webserver...{1}".format(colors.GREEN, colors.END), flush=True)
|
||||||
|
|
||||||
# Start Flask/SocketIO (Blocking, so this must be last method!)
|
# Start Flask/SocketIO (Blocking, so this must be last method!)
|
||||||
|
@ -5332,24 +5334,26 @@ if __name__ == "__main__":
|
||||||
cloudflare = _run_ngrok()
|
cloudflare = _run_ngrok()
|
||||||
elif(args.remote):
|
elif(args.remote):
|
||||||
from flask_cloudflared import _run_cloudflared
|
from flask_cloudflared import _run_cloudflared
|
||||||
cloudflare = _run_cloudflared(5000)
|
cloudflare = _run_cloudflared(port)
|
||||||
if(args.ngrok or args.remote):
|
if(args.ngrok or args.remote):
|
||||||
with open('cloudflare.log', 'w') as cloudflarelog:
|
with open('cloudflare.log', 'w') as cloudflarelog:
|
||||||
cloudflarelog.write("KoboldAI has finished loading and is available at the following link : " + cloudflare)
|
cloudflarelog.write("KoboldAI has finished loading and is available at the following link : " + cloudflare)
|
||||||
print(format(colors.GREEN) + "KoboldAI has finished loading and is available at the following link : " + cloudflare + format(colors.END))
|
print(format(colors.GREEN) + "KoboldAI has finished loading and is available at the following link : " + cloudflare + format(colors.END))
|
||||||
else:
|
else:
|
||||||
print("{0}Webserver has started, you can now connect to this machine at port 5000{1}".format(colors.GREEN, colors.END))
|
print("{0}Webserver has started, you can now connect to this machine at port 5000{1}"
|
||||||
|
.format(colors.GREEN, colors.END))
|
||||||
vars.serverstarted = True
|
vars.serverstarted = True
|
||||||
socketio.run(app, host='0.0.0.0', port=5000)
|
socketio.run(app, host='0.0.0.0', port=port)
|
||||||
else:
|
else:
|
||||||
import webbrowser
|
import webbrowser
|
||||||
webbrowser.open_new('http://localhost:5000')
|
webbrowser.open_new('http://localhost:{0}'.format(port))
|
||||||
print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:5000/{1}".format(colors.GREEN, colors.END))
|
print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:{1}/{2}"
|
||||||
|
.format(colors.GREEN, port, colors.END))
|
||||||
vars.serverstarted = True
|
vars.serverstarted = True
|
||||||
if args.unblock:
|
if args.unblock:
|
||||||
socketio.run(app, port=5000, host='0.0.0.0')
|
socketio.run(app, port=port, host='0.0.0.0')
|
||||||
else:
|
else:
|
||||||
socketio.run(app, port=5000)
|
socketio.run(app, port=port)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("{0}\nServer started in WSGI mode!{1}".format(colors.GREEN, colors.END), flush=True)
|
print("{0}\nServer started in WSGI mode!{1}".format(colors.GREEN, colors.END), flush=True)
|
||||||
|
|
|
@ -118,10 +118,33 @@ var adventure = false;
|
||||||
// Chatmode
|
// Chatmode
|
||||||
var chatmode = false;
|
var chatmode = false;
|
||||||
|
|
||||||
|
var sliders_throttle = getThrottle(200);
|
||||||
|
|
||||||
//=================================================================//
|
//=================================================================//
|
||||||
// METHODS
|
// METHODS
|
||||||
//=================================================================//
|
//=================================================================//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a function that will automatically wait for X ms before executing the callback
|
||||||
|
* The timer is reset each time the returned function is called
|
||||||
|
* Useful for methods where something is overridden too fast
|
||||||
|
* @param ms milliseconds to wait before executing the callback
|
||||||
|
* @return {(function(*): void)|*} function that takes the ms to wait and a callback to execute after the timer
|
||||||
|
*/
|
||||||
|
function getThrottle(ms) {
|
||||||
|
var timer = {};
|
||||||
|
|
||||||
|
return function (id, callback) {
|
||||||
|
if (timer[id]) {
|
||||||
|
clearTimeout(timer[id]);
|
||||||
|
}
|
||||||
|
timer[id] = setTimeout(function () {
|
||||||
|
callback();
|
||||||
|
delete timer[id];
|
||||||
|
}, ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addSetting(ob) {
|
function addSetting(ob) {
|
||||||
// Add setting block to Settings Menu
|
// Add setting block to Settings Menu
|
||||||
if(ob.uitype == "slider"){
|
if(ob.uitype == "slider"){
|
||||||
|
@ -153,8 +176,14 @@ function addSetting(ob) {
|
||||||
window["label_"+ob.id] = reflb; // Is this still needed?
|
window["label_"+ob.id] = reflb; // Is this still needed?
|
||||||
// Add event function to input
|
// Add event function to input
|
||||||
refin.on("input", function () {
|
refin.on("input", function () {
|
||||||
socket.send({'cmd': $(this).attr('id'), 'data': $(this).val()});
|
var that = this;
|
||||||
|
sliders_throttle(ob.id, function () {
|
||||||
|
socket.send({'cmd': $(that).attr('id'), 'data': $(that).val()});
|
||||||
|
refin.val(parseFloat($(that).val()));
|
||||||
|
reflb.html($(that).val());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
} else if(ob.uitype == "toggle"){
|
} else if(ob.uitype == "toggle"){
|
||||||
settings_menu.append("<div class=\"settingitem\">\
|
settings_menu.append("<div class=\"settingitem\">\
|
||||||
<input type=\"checkbox\" data-toggle=\"toggle\" data-onstyle=\"success\" id=\""+ob.id+"\">\
|
<input type=\"checkbox\" data-toggle=\"toggle\" data-onstyle=\"success\" id=\""+ob.id+"\">\
|
||||||
|
|
Loading…
Reference in New Issue