Skip to content

Commit c47bc28

Browse files
committed
slight refactor for noscript ui
1 parent 7469f20 commit c47bc28

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

koboldcpp.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ def noscript_webui(self):
635635
parsed_url = urlparse.urlparse(self.path)
636636
parsed_dict = urlparse.parse_qs(parsed_url.query)
637637
reply = ""
638-
status = parsed_dict['status'][0] if 'status' in parsed_dict else "Ready To Generate"
639-
prompt = parsed_dict['prompt'][0] if 'prompt' in parsed_dict else ""
638+
status = str(parsed_dict['status'][0]) if 'status' in parsed_dict else "Ready To Generate"
639+
prompt = str(parsed_dict['prompt'][0]) if 'prompt' in parsed_dict else ""
640640
max_length = int(parsed_dict['max_length'][0]) if 'max_length' in parsed_dict else 100
641641
temperature = float(parsed_dict['temperature'][0]) if 'temperature' in parsed_dict else 0.7
642642
top_k = int(parsed_dict['top_k'][0]) if 'top_k' in parsed_dict else 100
@@ -645,12 +645,14 @@ def noscript_webui(self):
645645
use_default_badwordsids = int(parsed_dict['use_default_badwordsids'][0]) if 'use_default_badwordsids' in parsed_dict else 0
646646
gencommand = (parsed_dict['generate'][0] if 'generate' in parsed_dict else "")=="Generate"
647647

648-
if gencommand:
648+
if modelbusy.locked():
649+
status = "Model is currently busy, try again later."
650+
elif gencommand:
649651
if prompt=="" or max_length<=0:
650652
status = "Need a valid prompt and length to generate."
651-
if modelbusy.locked():
652-
status = "Model is currently busy, try again later."
653653
else:
654+
if max_length>512:
655+
max_length = 512
654656
epurl = f"http://localhost:{args.port}"
655657
if args.host!="":
656658
epurl = f"http://{args.host}:{args.port}"
@@ -670,9 +672,6 @@ def noscript_webui(self):
670672
self.send_header("location", self.path)
671673
self.end_headers(content_type='text/html')
672674
return
673-
else:
674-
if modelbusy.locked():
675-
status = "Model is currently busy."
676675

677676
finalhtml = f'''<!doctype html>
678677
<html lang="en"><head>

0 commit comments

Comments
 (0)