From de2c5f1cef0b96ef63c5dd404aade0ebf10311ec Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sun, 17 May 2026 17:04:47 +0800 Subject: [PATCH] detokenize add special token ids --- expose.cpp | 4 ++-- expose.h | 6 ++++++ koboldcpp.py | 17 ++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/expose.cpp b/expose.cpp index 0d42e2a57..526538ce5 100644 --- a/expose.cpp +++ b/expose.cpp @@ -362,14 +362,14 @@ extern "C" } static std::string detokenized_str = ""; //just share a static object for detokenizing - const char * detokenize(const token_count_outputs input) + const char * detokenize(const detokenize_inputs input) { std::vector input_arr; for(int i=0;i 0 and tokidslen < 65536: - inputs = token_count_outputs() + inputs = detokenize_inputs() inputs.count = tokidslen + inputs.special = addspecial inputs.ids = (ctypes.c_int * tokidslen)() for i, cid in enumerate(tokids): inputs.ids[i] = cid @@ -4235,7 +4241,7 @@ ws ::= | " " | "\n" [ \t]{0,20} assistant_message_start = adapter_obj.get("assistant_start", "\n\n### Response:\n") assistant_message_gen = adapter_obj.get("assistant_gen", assistant_message_start) try: - detokstr = detokenize_ids(tokids) + detokstr = detokenize_ids(tokids,True) except Exception as e: utfprint("Ollama Context Error: " + str(e)) ollamasysprompt = genparams.get('system', "") @@ -6026,7 +6032,8 @@ Change Mode
try: genparams = json.loads(body) tokids = genparams.get('ids', []) - detokstr = detokenize_ids(tokids) + addspecial = genparams.get('special', True) + detokstr = detokenize_ids(tokids,addspecial) response_body = (json.dumps({"result": detokstr,"success":True}).encode()) except Exception as e: utfprint("Detokenize Error: " + str(e))