fix for chat templates and drafting

This commit is contained in:
Concedo 2025-01-23 11:49:40 +08:00
parent 03def285db
commit cca4a934dd
3 changed files with 27 additions and 11 deletions

View file

@ -59,7 +59,7 @@ maxhordelen = 400
modelbusy = threading.Lock()
requestsinqueue = 0
defaultport = 5001
KcppVersion = "1.82.3"
KcppVersion = "1.82.4"
showdebug = True
guimode = False
showsamplerwarning = True
@ -3421,7 +3421,7 @@ def show_gui():
def on_picked_model_file(filepath):
if filepath.lower().endswith('.kcpps') or filepath.lower().endswith('.kcppt'):
#load it as a config file instead
with open(filepath, 'r') as f:
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
dict = json.load(f)
import_vars(dict)
@ -4014,7 +4014,7 @@ def show_gui():
try:
if kcpp_exporting_template and isinstance(args.chatcompletionsadapter, str) and args.chatcompletionsadapter!="" and os.path.exists(args.chatcompletionsadapter):
print("Embedding chat completions adapter...") # parse and save embedded preload story
with open(args.chatcompletionsadapter, 'r') as f:
with open(args.chatcompletionsadapter, 'r', encoding='utf-8', errors='ignore') as f:
args.chatcompletionsadapter = json.load(f)
except Exception:
pass
@ -4025,7 +4025,7 @@ def show_gui():
try:
if kcpp_exporting_template and isinstance(args.preloadstory, str) and args.preloadstory!="" and os.path.exists(args.preloadstory):
print("Embedding preload story...") # parse and save embedded preload story
with open(args.preloadstory, 'r') as f:
with open(args.preloadstory, 'r', encoding='utf-8', errors='ignore') as f:
args.preloadstory = json.load(f)
except Exception:
pass
@ -4283,7 +4283,7 @@ def show_gui():
if not filename or filename=="":
return
runmode_untouched = False
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8', errors='ignore') as f:
dict = json.load(f)
import_vars(dict)
pass
@ -4761,7 +4761,7 @@ def unload_libs():
def load_config_cli(filename):
print("Loading .kcpps configuration file...")
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8', errors='ignore') as f:
config = json.load(f)
args.istemplate = False
raw_args = (sys.argv[1:]) #a lousy hack to allow for overriding kcpps
@ -4990,7 +4990,7 @@ def main(launch_args,start_server=True):
ccadapter_path = os.path.abspath(premade_adapt_path)
if ccadapter_path:
print(f"Loading Chat Completions Adapter: {ccadapter_path}")
with open(ccadapter_path, 'r') as f:
with open(ccadapter_path, 'r', encoding='utf-8', errors='replace') as f:
chatcompl_adapter = json.load(f)
canload = True
else: