mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 17:14:36 +00:00
fixed some incorrect protocol prefix for localhost
This commit is contained in:
parent
5f360f659c
commit
0f9968ef64
1 changed files with 13 additions and 10 deletions
23
koboldcpp.py
23
koboldcpp.py
|
@ -1612,7 +1612,7 @@ class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def noscript_webui(self):
|
def noscript_webui(self):
|
||||||
global modelbusy
|
global modelbusy, sslvalid
|
||||||
import html
|
import html
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
parsed_url = urlparse.urlparse(self.path)
|
parsed_url = urlparse.urlparse(self.path)
|
||||||
|
@ -1636,9 +1636,10 @@ class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
if max_length>512:
|
if max_length>512:
|
||||||
max_length = 512
|
max_length = 512
|
||||||
epurl = f"http://localhost:{args.port}"
|
httpsaffix = ("https" if sslvalid else "http")
|
||||||
|
epurl = f"{httpsaffix}://localhost:{args.port}"
|
||||||
if args.host!="":
|
if args.host!="":
|
||||||
epurl = f"http://{args.host}:{args.port}"
|
epurl = f"{httpsaffix}://{args.host}:{args.port}"
|
||||||
gen_payload = {"prompt": prompt,"max_length": max_length,"temperature": temperature,"prompt": prompt,"top_k": top_k,"top_p": top_p,"rep_pen": rep_pen,"ban_eos_token":ban_eos_token}
|
gen_payload = {"prompt": prompt,"max_length": max_length,"temperature": temperature,"prompt": prompt,"top_k": top_k,"top_p": top_p,"rep_pen": rep_pen,"ban_eos_token":ban_eos_token}
|
||||||
respjson = make_url_request(f'{epurl}/api/v1/generate', gen_payload)
|
respjson = make_url_request(f'{epurl}/api/v1/generate', gen_payload)
|
||||||
reply = html.escape(respjson["results"][0]["text"])
|
reply = html.escape(respjson["results"][0]["text"])
|
||||||
|
@ -3376,10 +3377,11 @@ def make_url_request(url, data, method='POST', headers={}):
|
||||||
def run_horde_worker(args, api_key, worker_name):
|
def run_horde_worker(args, api_key, worker_name):
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import random
|
import random
|
||||||
global friendlymodelname, maxhordectx, maxhordelen, exitcounter, punishcounter, modelbusy, session_starttime
|
global friendlymodelname, maxhordectx, maxhordelen, exitcounter, punishcounter, modelbusy, session_starttime, sslvalid
|
||||||
epurl = f"http://localhost:{args.port}"
|
httpsaffix = ("https" if sslvalid else "http")
|
||||||
|
epurl = f"{httpsaffix}://localhost:{args.port}"
|
||||||
if args.host!="":
|
if args.host!="":
|
||||||
epurl = f"http://{args.host}:{args.port}"
|
epurl = f"{httpsaffix}://{args.host}:{args.port}"
|
||||||
|
|
||||||
def submit_completed_generation(url, jobid, sessionstart, submit_dict):
|
def submit_completed_generation(url, jobid, sessionstart, submit_dict):
|
||||||
global exitcounter, punishcounter, session_kudos_earned, session_jobs, rewardcounter
|
global exitcounter, punishcounter, session_kudos_earned, session_jobs, rewardcounter
|
||||||
|
@ -3578,7 +3580,8 @@ def setuptunnel(has_sd):
|
||||||
# It should work out of the box on both linux and windows
|
# It should work out of the box on both linux and windows
|
||||||
try:
|
try:
|
||||||
import subprocess, re
|
import subprocess, re
|
||||||
|
global sslvalid
|
||||||
|
httpsaffix = ("https" if sslvalid else "http")
|
||||||
def run_tunnel():
|
def run_tunnel():
|
||||||
tunnelproc = None
|
tunnelproc = None
|
||||||
tunneloutput = ""
|
tunneloutput = ""
|
||||||
|
@ -3586,13 +3589,13 @@ def setuptunnel(has_sd):
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
print("Starting Cloudflare Tunnel for Windows, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for Windows, please wait...", flush=True)
|
||||||
tunnelproc = subprocess.Popen(f"cloudflared.exe tunnel --url localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
tunnelproc = subprocess.Popen(f"cloudflared.exe tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
||||||
elif sys.platform=="darwin":
|
elif sys.platform=="darwin":
|
||||||
print("Starting Cloudflare Tunnel for MacOS, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for MacOS, please wait...", flush=True)
|
||||||
tunnelproc = subprocess.Popen(f"./cloudflared tunnel --url http://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
tunnelproc = subprocess.Popen(f"./cloudflared tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
|
print("Starting Cloudflare Tunnel for Linux, please wait...", flush=True)
|
||||||
tunnelproc = subprocess.Popen(f"./cloudflared-linux-amd64 tunnel --url http://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
tunnelproc = subprocess.Popen(f"./cloudflared-linux-amd64 tunnel --url {httpsaffix}://localhost:{args.port}", text=True, encoding='utf-8', shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
def tunnel_reader():
|
def tunnel_reader():
|
||||||
nonlocal tunnelproc,tunneloutput,tunnelrawlog
|
nonlocal tunnelproc,tunneloutput,tunnelrawlog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue