allow drag and drop kcpps file and openwith

This commit is contained in:
Concedo 2023-10-05 11:38:37 +08:00
parent 47f7ebb632
commit ce065d39d0
2 changed files with 13 additions and 2 deletions

View file

@ -6224,6 +6224,10 @@ Current version: 75
document.getElementById('instruct_starttag').value = "\\nQuestion: "; document.getElementById('instruct_starttag').value = "\\nQuestion: ";
document.getElementById('instruct_endtag').value = "\\nAnswer: "; document.getElementById('instruct_endtag').value = "\\nAnswer: ";
break; break;
case "6": //ChatML
document.getElementById('instruct_starttag').value = "<|im_start|>user";
document.getElementById('instruct_endtag').value = "<|im_start|>assistant";
break;
default: default:
break; break;
} }
@ -9208,7 +9212,7 @@ Current version: 75
this.bubbleColor_AI = 'rgb(20, 20, 40)'; this.bubbleColor_AI = 'rgb(20, 20, 40)';
this.background_margin = [5, 5, 5, 0]; this.background_margin = [5, 5, 5, 0];
this.background_padding = [15, 15, 10, 10]; this.background_padding = [15, 15, 10, 5];
this.background_minHeight = 80; this.background_minHeight = 80;
this.centerHorizontally = false; this.centerHorizontally = false;
@ -10216,6 +10220,7 @@ Current version: 75
<option value="3">Metharme</option> <option value="3">Metharme</option>
<option value="4">Llama 2 Chat</option> <option value="4">Llama 2 Chat</option>
<option value="5">Q & A</option> <option value="5">Q & A</option>
<option value="6">ChatML</option>
</select> </select>
<table class="settingsmall text-center" style="border-spacing: 4px 2px; border-collapse: separate;"> <table class="settingsmall text-center" style="border-spacing: 4px 2px; border-collapse: separate;">
<tr> <tr>

View file

@ -791,7 +791,6 @@ def show_new_gui():
args.model_param = askopenfilename(title="Select ggml model .bin or .gguf file or .kcpps config") args.model_param = askopenfilename(title="Select ggml model .bin or .gguf file or .kcpps config")
root.destroy() root.destroy()
if args.model_param and args.model_param!="" and args.model_param.lower().endswith('.kcpps'): if args.model_param and args.model_param!="" and args.model_param.lower().endswith('.kcpps'):
print("\nLoading configuration...")
loadconfigfile(args.model_param) loadconfigfile(args.model_param)
if not args.model_param: if not args.model_param:
print("\nNo ggml model or kcpps file was selected. Exiting.") print("\nNo ggml model or kcpps file was selected. Exiting.")
@ -1585,6 +1584,7 @@ def unload_libs():
handle = None handle = None
def loadconfigfile(filename): def loadconfigfile(filename):
print("Loading kcpps configuration file...")
with open(filename, 'r') as f: with open(filename, 'r') as f:
config = json.load(f) config = json.load(f)
for key, value in config.items(): for key, value in config.items():
@ -1601,8 +1601,14 @@ def main(launch_args,start_server=True):
print("Specified kcpp config file invalid or not found.") print("Specified kcpp config file invalid or not found.")
time.sleep(3) time.sleep(3)
sys.exit(2) sys.exit(2)
#positional handling for kcpps files (drag and drop)
if args.model_param and args.model_param!="" and args.model_param.lower().endswith('.kcpps'):
loadconfigfile(args.model_param)
if not args.model_param: if not args.model_param:
args.model_param = args.model args.model_param = args.model
if not args.model_param: if not args.model_param:
#give them a chance to pick a file #give them a chance to pick a file
print("For command line arguments, please refer to --help") print("For command line arguments, please refer to --help")