safer autoguess fix

verbose outputs (+3 squashed commit)

Squashed commit:

[7bbbfc10] fixed a retry history bug

[824b9bf7] another autoguess fix
This commit is contained in:
Concedo 2025-02-16 17:10:20 +08:00
parent e0bdb2f622
commit 58380153b2
2 changed files with 24 additions and 9 deletions

View file

@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
--> -->
<script> <script>
const LITEVER = 214; const LITEVER = 215;
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
var localflag = true; var localflag = true;
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_"; const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@ -11842,7 +11842,7 @@ Current version indicated by LITEVER below.
}); });
} }
function clear_poll_flags() function restore_retried_text()
{ {
if(retry_in_progress) if(retry_in_progress)
{ {
@ -11857,6 +11857,10 @@ Current version indicated by LITEVER below.
} }
} }
} }
}
function clear_poll_flags()
{
restore_retried_text();
pending_response_id = ""; pending_response_id = "";
poll_in_progress = false; poll_in_progress = false;
synchro_polled_response = null; synchro_polled_response = null;
@ -16413,6 +16417,7 @@ Current version indicated by LITEVER below.
handle_incoming_text(gentxt, genworker, genmdl, genkudos); handle_incoming_text(gentxt, genworker, genmdl, genkudos);
} }
}else{ }else{
restore_retried_text();
retry_preserve_last = false; retry_preserve_last = false;
} }
synchro_polled_response = null; synchro_polled_response = null;
@ -16473,7 +16478,13 @@ Current version indicated by LITEVER below.
} }
else { else {
last_reply_was_empty = (gentxt=="" || gentxt.trim()==""); last_reply_was_empty = (gentxt=="" || gentxt.trim()=="");
let was_retry_in_progress = retry_in_progress;
handle_incoming_text(gentxt, genworker, genmdl, genkudos); handle_incoming_text(gentxt, genworker, genmdl, genkudos);
if (gentxt=="" && was_retry_in_progress)
{
retry_in_progress = was_retry_in_progress;
restore_retried_text(); //horde only: this handles the case when the retry returned empty text, we restore the old text
}
} }
} }
render_gametext(); render_gametext();

View file

@ -48,7 +48,7 @@ logit_bias_max = 512
dry_seq_break_max = 128 dry_seq_break_max = 128
# global vars # global vars
KcppVersion = "1.84.1" KcppVersion = "1.84.2"
showdebug = True showdebug = True
kcpp_instance = None #global running instance kcpp_instance = None #global running instance
global_memory = {"tunnel_url": "", "restart_target":"", "input_to_exit":False, "load_complete":False} global_memory = {"tunnel_url": "", "restart_target":"", "input_to_exit":False, "load_complete":False}
@ -95,6 +95,7 @@ websearch_lastquery = ""
websearch_lastresponse = [] websearch_lastresponse = []
preloaded_story = None preloaded_story = None
chatcompl_adapter = None chatcompl_adapter = None
chatcompl_adapter_list = None #if using autoguess, will populate this will potential adapters
embedded_kailite = None embedded_kailite = None
embedded_kcpp_docs = None embedded_kcpp_docs = None
embedded_kcpp_sdui = None embedded_kcpp_sdui = None
@ -4951,6 +4952,9 @@ def main(launch_args):
print(f"***\nWelcome to KoboldCpp - Version {KcppVersion}") print(f"***\nWelcome to KoboldCpp - Version {KcppVersion}")
if args.debugmode != 1: if args.debugmode != 1:
showdebug = False #not shared with child process! showdebug = False #not shared with child process!
if args.debugmode >= 1:
print("Debug Mode is Enabled!")
args.quiet = False # verbose outputs
try: try:
delete_old_pyinstaller() #perform some basic cleanup of old temporary directories delete_old_pyinstaller() #perform some basic cleanup of old temporary directories
@ -5136,7 +5140,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
# try to read chat completions adapter # try to read chat completions adapter
if args.chatcompletionsadapter: if args.chatcompletionsadapter:
global chatcompl_adapter global chatcompl_adapter, chatcompl_adapter_list
ccadapter_path = None ccadapter_path = None
canload = False canload = False
adapt_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'kcpp_adapters') adapt_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'kcpp_adapters')
@ -5176,6 +5180,9 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
print("Chat Completions Adapter Loaded") print("Chat Completions Adapter Loaded")
else: else:
print("Warning: Chat Completions Adapter invalid or not found.") print("Warning: Chat Completions Adapter invalid or not found.")
if (chatcompl_adapter is not None and isinstance(chatcompl_adapter, list)):
chatcompl_adapter_list = chatcompl_adapter
chatcompl_adapter = None
# handle model downloads if needed # handle model downloads if needed
if args.model_param and args.model_param!="": if args.model_param and args.model_param!="":
@ -5383,23 +5390,20 @@ 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)): if (chatcompl_adapter_list is not None and isinstance(chatcompl_adapter_list, 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
if not args.nomodel and args.model_param: if not args.nomodel and args.model_param:
ctbytes = handle.get_chat_template() ctbytes = handle.get_chat_template()
chat_template = ctypes.string_at(ctbytes).decode("UTF-8","ignore") chat_template = ctypes.string_at(ctbytes).decode("UTF-8","ignore")
candidates = chatcompl_adapter
if chat_template != "": if chat_template != "":
for entry in candidates: for entry in chatcompl_adapter_list:
if all(s in chat_template for s in entry['search']): if all(s in chat_template for s in entry['search']):
print(f"Chat completion heuristic: {entry['name']}") print(f"Chat completion heuristic: {entry['name']}")
chatcompl_adapter = entry['adapter'] chatcompl_adapter = entry['adapter']
break break
if chatcompl_adapter is None: if chatcompl_adapter is None:
print("Chat template heuristics failed to identify chat completions format. Alpaca will be used.") print("Chat template heuristics failed to identify chat completions format. Alpaca will be used.")
else:
chatcompl_adapter = None #if no text model loaded, erase the list.
#handle loading image model #handle loading image model
if args.sdmodel and args.sdmodel!="": if args.sdmodel and args.sdmodel!="":