Added --remote Mode
First step towards native Colab support, built in Cloudflare tunnels easily allows players to play KoboldAI on another device. This mode also removes buttons that would get you stuck if you have no local PC access.
This commit is contained in:
parent
9760c159fd
commit
136dd71171
21
aiserver.py
21
aiserver.py
|
@ -12,6 +12,7 @@ from tkinter import messagebox
|
|||
import json
|
||||
import requests
|
||||
import html
|
||||
import argparse
|
||||
|
||||
# KoboldAI
|
||||
import fileops
|
||||
|
@ -103,6 +104,7 @@ class vars:
|
|||
acregex_ui = re.compile(r'^ *(>.*)$', re.MULTILINE) # Pattern for matching actions in the HTML-escaped story so we can apply colouring, etc (make sure to encase part to format in parentheses)
|
||||
actionmode = 1
|
||||
adventure = False
|
||||
remote = False
|
||||
|
||||
#==================================================================#
|
||||
# Function to get model selection at startup
|
||||
|
@ -152,6 +154,14 @@ def gettokenids(char):
|
|||
# Startup
|
||||
#==================================================================#
|
||||
|
||||
# Parsing Parameters
|
||||
parser = argparse.ArgumentParser(description="My Script")
|
||||
parser.add_argument("--remote", action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.remote:
|
||||
vars.remote = True;
|
||||
|
||||
# Select a model to run
|
||||
print("{0}Welcome to the KoboldAI Client!\nSelect an AI model to continue:{1}\n".format(colors.CYAN, colors.END))
|
||||
getModelSelection()
|
||||
|
@ -373,6 +383,9 @@ def index():
|
|||
def do_connect():
|
||||
print("{0}Client connected!{1}".format(colors.GREEN, colors.END))
|
||||
emit('from_server', {'cmd': 'connected'})
|
||||
if(vars.remote):
|
||||
emit('from_server', {'cmd': 'runs_remotely'})
|
||||
|
||||
if(not vars.gamestarted):
|
||||
setStartState()
|
||||
sendsettings()
|
||||
|
@ -1900,10 +1913,18 @@ def randomGameRequest(topic):
|
|||
# Final startup commands to launch Flask app
|
||||
#==================================================================#
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Load settings from client.settings
|
||||
loadsettings()
|
||||
|
||||
# Start Flask/SocketIO (Blocking, so this must be last method!)
|
||||
print("{0}Server started!\rYou may now connect with a browser at http://127.0.0.1:5000/{1}".format(colors.GREEN, colors.END))
|
||||
#socketio.run(app, host='0.0.0.0', port=5000)
|
||||
if(vars.remote):
|
||||
from flask_cloudflared import start_cloudflared
|
||||
start_cloudflared(5000)
|
||||
socketio.run(app, host='0.0.0.0', port=5000)
|
||||
else:
|
||||
import webbrowser
|
||||
webbrowser.open_new('http://localhost:5000')
|
||||
socketio.run(app)
|
|
@ -13,3 +13,4 @@ dependencies:
|
|||
- git
|
||||
- pip:
|
||||
- git+https://github.com/finetuneanon/transformers@gpt-neo-localattention3-rp-b
|
||||
- flask-cloudflared
|
|
@ -10,3 +10,6 @@ dependencies:
|
|||
- pytorch
|
||||
- tensorflow-gpu
|
||||
- transformers
|
||||
- pip
|
||||
- pip:
|
||||
- flask-cloudflared
|
4
play.bat
4
play.bat
|
@ -7,12 +7,12 @@ IF %M%==2 GOTO subfolder
|
|||
|
||||
:subfolder
|
||||
call miniconda3\condabin\activate
|
||||
python aiserver.py
|
||||
python aiserver.py %*
|
||||
cmd /k
|
||||
|
||||
:drivemap
|
||||
subst K: miniconda3 >nul
|
||||
call K:\python\condabin\activate
|
||||
python aiserver.py
|
||||
python aiserver.py %*
|
||||
subst K: /D
|
||||
cmd /k
|
|
@ -4,3 +4,4 @@ Flask == 1.1.2
|
|||
Flask-SocketIO == 5.0.1
|
||||
requests == 2.25.1
|
||||
torch == 1.8.1
|
||||
flask-cloudflared
|
|
@ -926,6 +926,8 @@ $(document).ready(function(){
|
|||
$("#setadventure").prop('checked', msg.data).change();
|
||||
// Update adventure state
|
||||
setadventure(msg.data);
|
||||
} else if(msg.cmd == "runs_remotely") {
|
||||
hide([button_loadfrfile, button_savetofile, button_import, button_importwi]);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue