From 349c4614534c1cc28668b88c9469eb6773a7a6b0 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:23:18 +0800 Subject: [PATCH] add stop reason for error --- embd_res/klite.embd | 9 ++------- expose.h | 1 + gpttype_adapter.cpp | 12 ++++++++---- koboldcpp.py | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/embd_res/klite.embd b/embd_res/klite.embd index df88ae1f9..5181ab453 100644 --- a/embd_res/klite.embd +++ b/embd_res/klite.embd @@ -1384,7 +1384,7 @@ Current version indicated by LITEVER below. padding-right: 6px; } #actionmenuitems button.slim,#actionmenuitems2 button.slim { - width: 38px; + width: 34px; padding-left: 4px; padding-right: 4px; } @@ -21092,12 +21092,7 @@ Current version indicated by LITEVER below. //something went wrong. clear_poll_flags(); render_gametext(); - if (data.message != "") { - msgbox(data.message); - } - else { - msgbox("Unspecified error while submitting prompt"); - } + msgbox("Error Submitting Prompt: " + JSON.stringify(data)); } }) .catch((error) => { diff --git a/expose.h b/expose.h index 16514bca8..b583d8570 100644 --- a/expose.h +++ b/expose.h @@ -21,6 +21,7 @@ enum samplers }; enum stop_reason { + ERROR_ENCOUNTERED=-2, INVALID=-1, OUT_OF_TOKENS=0, EOS_TOKEN_HIT=1, diff --git a/gpttype_adapter.cpp b/gpttype_adapter.cpp index 67ff62766..ff28fead3 100644 --- a/gpttype_adapter.cpp +++ b/gpttype_adapter.cpp @@ -3396,7 +3396,8 @@ generation_outputs gpttype_generate(const generation_inputs inputs) output.text = nullptr; output.status = 0; output.prompt_tokens = output.completion_tokens = 0; - output.stopreason = stop_reason::INVALID; + last_stop_reason = stop_reason::ERROR_ENCOUNTERED; + output.stopreason = last_stop_reason; generation_finished = true; return output; } @@ -4482,7 +4483,8 @@ generation_outputs gpttype_generate(const generation_inputs inputs) output.text = nullptr; output.status = 0; output.prompt_tokens = output.completion_tokens = 0; - output.stopreason = stop_reason::INVALID; + last_stop_reason = stop_reason::ERROR_ENCOUNTERED; + output.stopreason = last_stop_reason; generation_finished = true; return output; } @@ -4944,7 +4946,8 @@ generation_outputs gpttype_generate(const generation_inputs inputs) output.text = nullptr; output.status = 0; output.prompt_tokens = output.completion_tokens = 0; - output.stopreason = stop_reason::INVALID; + last_stop_reason = stop_reason::ERROR_ENCOUNTERED; + output.stopreason = last_stop_reason; generation_finished = true; return output; } @@ -4974,7 +4977,8 @@ generation_outputs gpttype_generate(const generation_inputs inputs) output.text = nullptr; output.status = 0; output.prompt_tokens = output.completion_tokens = 0; - output.stopreason = stop_reason::INVALID; + last_stop_reason = stop_reason::ERROR_ENCOUNTERED; + output.stopreason = last_stop_reason; generation_finished = true; return output; } diff --git a/koboldcpp.py b/koboldcpp.py index 078045ab8..7435e5a7b 100755 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -67,7 +67,7 @@ dry_seq_break_max = 128 extra_images_max = 4 # for kontext/qwen img # global vars -KcppVersion = "1.107.1" +KcppVersion = "1.107.2" showdebug = True kcpp_instance = None #global running instance global_memory = {"tunnel_url": "", "restart_target":"", "input_to_exit":False, "load_complete":False, "restart_override_config_target":""} @@ -3383,7 +3383,7 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler): recvtxt = genout['text'] prompttokens = genout['prompt_tokens'] comptokens = genout['completion_tokens'] - currfinishreason = ("length" if (genout['stopreason'] != 1) else "stop") + currfinishreason = "error" if (genout['stopreason'] == -2) else ("length" if (genout['stopreason'] != 1) else "stop") # grab logprobs if not streaming logprobsdict = None @@ -3476,7 +3476,7 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler): streamDone = handle.has_finished() #exit next loop on done if streamDone: sr = handle.get_last_stop_reason() - currfinishreason = ("length" if (sr!=1) else "stop") + currfinishreason = "error" if sr==-2 else ("length" if (sr!=1) else "stop") tokenStr = "" streamcount = handle.get_stream_count() while current_token < streamcount: