Skip to content

Commit

Permalink
slight refactor for noscript ui
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRuins committed Dec 8, 2023
1 parent 7469f20 commit c47bc28
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions koboldcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ def noscript_webui(self):
parsed_url = urlparse.urlparse(self.path)
parsed_dict = urlparse.parse_qs(parsed_url.query)
reply = ""
status = parsed_dict['status'][0] if 'status' in parsed_dict else "Ready To Generate"
prompt = parsed_dict['prompt'][0] if 'prompt' in parsed_dict else ""
status = str(parsed_dict['status'][0]) if 'status' in parsed_dict else "Ready To Generate"
prompt = str(parsed_dict['prompt'][0]) if 'prompt' in parsed_dict else ""
max_length = int(parsed_dict['max_length'][0]) if 'max_length' in parsed_dict else 100
temperature = float(parsed_dict['temperature'][0]) if 'temperature' in parsed_dict else 0.7
top_k = int(parsed_dict['top_k'][0]) if 'top_k' in parsed_dict else 100
Expand All @@ -645,12 +645,14 @@ def noscript_webui(self):
use_default_badwordsids = int(parsed_dict['use_default_badwordsids'][0]) if 'use_default_badwordsids' in parsed_dict else 0
gencommand = (parsed_dict['generate'][0] if 'generate' in parsed_dict else "")=="Generate"

if gencommand:
if modelbusy.locked():
status = "Model is currently busy, try again later."
elif gencommand:
if prompt=="" or max_length<=0:
status = "Need a valid prompt and length to generate."
if modelbusy.locked():
status = "Model is currently busy, try again later."
else:
if max_length>512:
max_length = 512
epurl = f"http://localhost:{args.port}"
if args.host!="":
epurl = f"http://{args.host}:{args.port}"
Expand All @@ -670,9 +672,6 @@ def noscript_webui(self):
self.send_header("location", self.path)
self.end_headers(content_type='text/html')
return
else:
if modelbusy.locked():
status = "Model is currently busy."

finalhtml = f'''<!doctype html>
<html lang="en"><head>
Expand Down

0 comments on commit c47bc28

Please sign in to comment.