mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge commit 'refs/pull/378/head' of https://github.com/ebolam/KoboldAI into united
This commit is contained in:
40
aiserver.py
40
aiserver.py
@@ -1494,7 +1494,7 @@ def general_startup(override_args=None):
|
||||
parser.add_argument("--noaimenu", action='store_true', help="Disables the ability to select the AI")
|
||||
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", type=str, default="", nargs="?", const="", help="Optimizes KoboldAI for LAN Remote Play without using a proxy service. --host opens to all LAN. Enable IP whitelisting by using a comma separated IP list. Supports individual IPs, ranges, and subnets --host 127.0.0.1,127.0.0.2,127.0.0.3,192.168.1.0-192.168.1.255,10.0.0.0/24,etc")
|
||||
parser.add_argument("--host", type=str, default="Disabled", nargs="?", const="", help="Optimizes KoboldAI for LAN Remote Play without using a proxy service. --host opens to all LAN. Enable IP whitelisting by using a comma separated IP list. Supports individual IPs, ranges, and subnets --host 127.0.0.1,127.0.0.2,127.0.0.3,192.168.1.0-192.168.1.255,10.0.0.0/24,etc")
|
||||
parser.add_argument("--port", type=int, help="Specify the port on which the application will be joinable")
|
||||
parser.add_argument("--aria2_port", type=int, help="Specify the port on which aria2's RPC interface will be open if aria2 is installed (defaults to 6799)")
|
||||
parser.add_argument("--model", help="Specify the Model Type to skip the Menu")
|
||||
@@ -1625,17 +1625,14 @@ def general_startup(override_args=None):
|
||||
if args.localtunnel:
|
||||
koboldai_vars.host = True;
|
||||
|
||||
if args.host == "":
|
||||
koboldai_vars.host = True
|
||||
args.unblock = True
|
||||
if args.host:
|
||||
if args.host != "Disabled":
|
||||
# This means --host option was submitted without an argument
|
||||
# Enable all LAN IPs (0.0.0.0/0)
|
||||
koboldai_vars.host = True
|
||||
args.unblock = True
|
||||
if args.host != "":
|
||||
# Check if --host option was submitted with an argument
|
||||
# Parse the supplied IP(s) and add them to the allowed IPs list
|
||||
koboldai_vars.host = True
|
||||
args.unblock = True
|
||||
enable_whitelist = True
|
||||
for ip_str in args.host.split(","):
|
||||
if "/" in ip_str:
|
||||
@@ -1652,6 +1649,7 @@ def general_startup(override_args=None):
|
||||
print(f"Allowed IPs: {allowed_ips}")
|
||||
|
||||
|
||||
|
||||
if args.cpu:
|
||||
koboldai_vars.use_colab_tpu = False
|
||||
|
||||
@@ -3504,7 +3502,8 @@ def is_allowed_ip():
|
||||
client_ip = request.remote_addr
|
||||
if request.path != '/genre_data.json':
|
||||
print("Connection Attempt: " + request.remote_addr)
|
||||
print("Allowed?: ", request.remote_addr in allowed_ips)
|
||||
if allowed_ips:
|
||||
print("Allowed?: ", request.remote_addr in allowed_ips)
|
||||
return client_ip in allowed_ips
|
||||
|
||||
|
||||
@@ -4203,7 +4202,8 @@ def execute_outmod():
|
||||
@socketio.on('connect')
|
||||
def do_connect():
|
||||
print("Connection Attempt: " + request.remote_addr)
|
||||
print("Allowed?: ", request.remote_addr in allowed_ips)
|
||||
if allowed_ips:
|
||||
print("Allowed?: ", request.remote_addr in allowed_ips)
|
||||
if request.args.get("rely") == "true":
|
||||
return
|
||||
logger.info("Client connected! UI_{}".format(request.args.get('ui')))
|
||||
@@ -7466,7 +7466,7 @@ def loadRequest(loadpath, filename=None):
|
||||
|
||||
if not loadpath:
|
||||
return
|
||||
|
||||
|
||||
start_time = time.time()
|
||||
# Leave Edit/Memory mode before continuing
|
||||
exitModes()
|
||||
@@ -7474,17 +7474,17 @@ def loadRequest(loadpath, filename=None):
|
||||
# Read file contents into JSON object
|
||||
start_time = time.time()
|
||||
if(isinstance(loadpath, str)):
|
||||
#Original UI only sends the story name and assumes it's always a .json file... here we check to see if it's a directory to load that way
|
||||
if not os.path.exists(loadpath):
|
||||
if os.path.exists(loadpath.replace(".json", "")):
|
||||
loadpath = loadpath.replace(".json", "")
|
||||
|
||||
if os.path.isdir(loadpath):
|
||||
if not valid_v3_story(loadpath):
|
||||
raise RuntimeError(f"Tried to load {loadpath}, a non-save directory.")
|
||||
koboldai_vars.update_story_path_structure(loadpath)
|
||||
loadpath = os.path.join(loadpath, "story.json")
|
||||
#Original UI only sends the story name and assumes it's always a .json file... here we check to see if it's a directory to load that way
|
||||
if not isinstance(loadpath, dict) and not os.path.exists(loadpath):
|
||||
if os.path.exists(loadpath.replace(".json", "")):
|
||||
loadpath = loadpath.replace(".json", "")
|
||||
|
||||
if not isinstance(loadpath, dict) and os.path.isdir(loadpath):
|
||||
if not valid_v3_story(loadpath):
|
||||
raise RuntimeError(f"Tried to load {loadpath}, a non-save directory.")
|
||||
koboldai_vars.update_story_path_structure(loadpath)
|
||||
loadpath = os.path.join(loadpath, "story.json")
|
||||
|
||||
with open(loadpath, "r", encoding="utf-8") as file:
|
||||
js = json.load(file)
|
||||
from_file=loadpath
|
||||
|
Reference in New Issue
Block a user