fixed autoguess breaking img gen

This commit is contained in:
Concedo 2025-02-14 11:34:43 +08:00
parent 39fad991cc
commit 6e6043fffe

View file

@ -5355,21 +5355,22 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
exitcounter = 999 exitcounter = 999
exit_with_error(3,"Could not load text model: " + modelname) exit_with_error(3,"Could not load text model: " + modelname)
if (chatcompl_adapter is not None and isinstance(chatcompl_adapter, list) and not args.nomodel and args.model_param): if (chatcompl_adapter is not None and isinstance(chatcompl_adapter, list)):
# The chat completions adapter is a list that needs derivation from chat templates # The chat completions adapter is a list that needs derivation from chat templates
# Try to derive chat completions adapter from chat template, now that we have the model loaded # Try to derive chat completions adapter from chat template, now that we have the model loaded
ctbytes = handle.get_chat_template() chatcompl_adapter = None #if no text model loaded, erase the list.
chat_template = ctypes.string_at(ctbytes).decode("UTF-8","ignore") if not args.nomodel and args.model_param:
candidates = chatcompl_adapter ctbytes = handle.get_chat_template()
chatcompl_adapter = None chat_template = ctypes.string_at(ctbytes).decode("UTF-8","ignore")
if chat_template != "": candidates = chatcompl_adapter
for entry in candidates: if chat_template != "":
if all(s in chat_template for s in entry['search']): for entry in candidates:
print(f"Chat completion heuristic: {entry['name']}") if all(s in chat_template for s in entry['search']):
chatcompl_adapter = entry['adapter'] print(f"Chat completion heuristic: {entry['name']}")
break chatcompl_adapter = entry['adapter']
if chatcompl_adapter is None: break
print("Chat template heuristics failed to identify chat completions format. Alpaca will be used.") if chatcompl_adapter is None:
print("Chat template heuristics failed to identify chat completions format. Alpaca will be used.")
#handle loading image model #handle loading image model
if args.sdmodel and args.sdmodel!="": if args.sdmodel and args.sdmodel!="":