mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
LocalTunnel support
This commit is contained in:
25
aiserver.py
25
aiserver.py
@ -778,6 +778,7 @@ def spRequest(filename):
|
||||
parser = argparse.ArgumentParser(description="KoboldAI Server")
|
||||
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("--localtunnel", action='store_true', help="Optimizes KoboldAI for Remote Play using Localtunnel")
|
||||
parser.add_argument("--host", action='store_true', help="Optimizes KoboldAI for Remote Play without using a proxy service")
|
||||
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)")
|
||||
@ -823,6 +824,9 @@ if args.remote:
|
||||
if args.ngrok:
|
||||
vars.host = True;
|
||||
|
||||
if args.localtunnel:
|
||||
vars.host = True;
|
||||
|
||||
if args.host:
|
||||
vars.host = True;
|
||||
|
||||
@ -5327,13 +5331,30 @@ if __name__ == "__main__":
|
||||
|
||||
#socketio.run(app, host='0.0.0.0', port=5000)
|
||||
if(vars.host):
|
||||
if(args.ngrok):
|
||||
if(args.localtunnel):
|
||||
import subprocess
|
||||
localtunnel = subprocess.Popen(['lt', '-p', '5000', 'http'], shell=True, stdout=subprocess.PIPE)
|
||||
attempts = 0
|
||||
while attempts < 10:
|
||||
try:
|
||||
cloudflare = str(localtunnel.stdout.readline())
|
||||
cloudflare = (re.search("(?P<url>https?:\/\/[^\s]+loca.lt)", cloudflare).group("url"))
|
||||
break
|
||||
except:
|
||||
attempts += 1
|
||||
time.sleep(3)
|
||||
continue
|
||||
if attempts == 10:
|
||||
print("LocalTunnel could not be created, falling back to cloudflare...")
|
||||
from flask_cloudflared import _run_cloudflared
|
||||
cloudflare = _run_cloudflared(5000)
|
||||
elif(args.ngrok):
|
||||
from flask_ngrok import _run_ngrok
|
||||
cloudflare = _run_ngrok()
|
||||
elif(args.remote):
|
||||
from flask_cloudflared import _run_cloudflared
|
||||
cloudflare = _run_cloudflared(5000)
|
||||
if(args.ngrok or args.remote):
|
||||
if(args.localtunnel or args.ngrok or args.remote):
|
||||
with open('cloudflare.log', 'w') as cloudflarelog:
|
||||
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))
|
||||
|
Reference in New Issue
Block a user