From 4212f0b8e8bd542372f45b481ca101e01d618751 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 15 Mar 2025 10:50:36 +0800 Subject: [PATCH] wip on multiple fixes --- gpttype_adapter.cpp | 2 +- klite.embd | 213 ++++++++++++++++++++++++++++++-------------- koboldcpp.py | 5 ++ simpleclinfo.cpp | 4 +- simpleclinfo.exe | Bin 154624 -> 156672 bytes 5 files changed, 154 insertions(+), 70 deletions(-) diff --git a/gpttype_adapter.cpp b/gpttype_adapter.cpp index e5f18ec95..66de0e731 100644 --- a/gpttype_adapter.cpp +++ b/gpttype_adapter.cpp @@ -2250,7 +2250,7 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in { printf("\nAttempting to apply Multimodal Projector: %s\n", mmproj_filename.c_str()); #if defined(GGML_USE_METAL) - if(file_format_meta.model_architecture == GGUFArch::ARCH_QWEN2VL) + if(file_format_meta.model_architecture == GGUFArch::ARCH_QWEN2VL || file_format_meta.model_architecture == GGUFArch::ARCH_GEMMA3) { set_clip_uses_gpu(false); printf("Clip will use CPU for this model!\n"); diff --git a/klite.embd b/klite.embd index 19e6c42f7..0b13adea2 100644 --- a/klite.embd +++ b/klite.embd @@ -3159,6 +3159,7 @@ Current version indicated by LITEVER below. img_cfgscale: 7, img_allowhd: true, img_crop: false, + img_newturn: false, img_img2imgstr: 0.6, img_clipskip: -1, img_steps: 20, @@ -3384,7 +3385,7 @@ Current version indicated by LITEVER below. }, { "id":14, - "name":"KoboldCppAutoGuess", + "name":"KoboldCppAutomatic", "user":"{{[INPUT]}}", "user_end":"", "assistant":"{{[OUTPUT]}}", @@ -5794,6 +5795,16 @@ Current version indicated by LITEVER below. { let imgid = resp.prompt_id.toString(); let nimgtag = "[<|p|" + imgid + "|p|>]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } gametext_arr.push(nimgtag); image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:prompt, poll_category:2 }; image_db[imgid].aspect = (req_payload.params.width>=req_payload.params.height*2?5:(req_payload.params.height>=req_payload.params.width*2?4:(req_payload.params.width>req_payload.params.height?2:(req_payload.params.width{ @@ -11072,6 +11089,7 @@ Current version indicated by LITEVER below. document.getElementById("tokenstreammode").value = localsettings.tokenstreammode; document.getElementById("img_allowhd").checked = localsettings.img_allowhd; document.getElementById("img_crop").checked = localsettings.img_crop; + document.getElementById("img_newturn").checked = localsettings.img_newturn; document.getElementById("img_autogen").checked = localsettings.img_autogen; document.getElementById("img_gen_from_instruct").checked = localsettings.img_gen_from_instruct; document.getElementById("save_images").checked = localsettings.save_images; @@ -11449,6 +11467,7 @@ Current version indicated by LITEVER below. localsettings.grammar = pendinggrammar; localsettings.tokenstreammode = document.getElementById("tokenstreammode").value; localsettings.img_crop = (document.getElementById("img_crop").checked ? true : false); + localsettings.img_newturn = (document.getElementById("img_newturn").checked ? true : false); localsettings.img_allowhd = (document.getElementById("img_allowhd").checked ? true : false); localsettings.img_autogen = (document.getElementById("img_autogen").checked ? true : false); localsettings.img_gen_from_instruct = (document.getElementById("img_gen_from_instruct").checked ? true : false); @@ -12733,6 +12752,16 @@ Current version indicated by LITEVER below. { let imgid = "selfuploadimg"+(Math.floor(10000 + Math.random() * 90000)).toString(); let nimgtag = "[<|p|" + imgid + "|p|>]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } gametext_arr.push(nimgtag); image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:"", poll_category:0 }; image_db[imgid].aspect = 0; @@ -13474,6 +13503,80 @@ Current version indicated by LITEVER below. return Math.max(1, Math.floor(((maxctxlen - maxgenamt)) * chars_per_token) - 12); } + function wrap_newgen_instruct_format(newgen, addendtag) + { + let ist = instructstartplaceholder; + let iet = instructendplaceholder; + let iste = instructstartplaceholder_end; + if (!localsettings.placeholder_tags) { + ist = get_instruct_starttag(false); + iet = get_instruct_endtag(false); + iste = get_instruct_starttag_end(false); + } + let prev_et = get_instruct_latest_end(false); + + if(newgen != "") + { + if(localsettings.inject_chatnames_instruct) + { + newgen = get_my_multiplayer_chatname() + ": " + newgen; + } + if(localsettings.inject_timestamps) + { + newgen = "["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"] " + newgen; + } + + //append instruction for instruct mode + if(localsettings.separate_end_tags) + { + newgen = prev_et + ist + newgen + iste + (addendtag?iet:""); + } + else + { + newgen = ist + newgen + (addendtag?iet:""); + } + + if(localsettings.inject_jailbreak_instruct) + { + newgen = newgen + localsettings.custom_jailbreak_text.replaceAll("\\n", "\n"); + } + if(force_thinking_tag && start_thinking_tag!="") + { + newgen = newgen + start_thinking_tag.replaceAll("\\n", "\n"); + } + } + else //may be continuting existing instruction OR starting a brand new session. check if first action + { + if (is_impersonate_user) { + is_impersonate_user = false; + if (localsettings.separate_end_tags) { + pending_context_preinjection = prev_et + ist; //bot response as first msg + pending_context_postinjection = iste + iet; + } else { + pending_context_preinjection = ist; //bot response as first msg + pending_context_postinjection = iet; + } + } else { + if (gametext_arr.length == 0) { + newgen = iet; + } + } + } + return newgen; + } + + function wrap_newgen_chat_format(newgen) + { + //append chatname for chatmode + let injecttime = ""; + if(localsettings.inject_timestamps) + { + injecttime = " ["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"]"; + } + newgen = "\n" + get_my_multiplayer_chatname() + ":"+ injecttime +" "+ newgen + ""; + return newgen; + } + function prepare_submit_generation() //wrap websearch into this { let senttext = document.getElementById("input_text").value; @@ -13536,72 +13639,10 @@ Current version indicated by LITEVER below. if (localsettings.opmode == 4) { - let ist = instructstartplaceholder; - let iet = instructendplaceholder; - let iste = instructstartplaceholder_end; - if (!localsettings.placeholder_tags) { - ist = get_instruct_starttag(false); - iet = get_instruct_endtag(false); - iste = get_instruct_starttag_end(false); - } - let prev_et = get_instruct_latest_end(false); - - if(newgen != "") - { - if(localsettings.inject_chatnames_instruct) - { - newgen = get_my_multiplayer_chatname() + ": " + newgen; - } - if(localsettings.inject_timestamps) - { - newgen = "["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"] " + newgen; - } - - //append instruction for instruct mode - if(localsettings.separate_end_tags) - { - newgen = prev_et + ist + newgen + iste + iet; - } - else - { - newgen = ist + newgen + iet; - } - - if(localsettings.inject_jailbreak_instruct) - { - newgen = newgen + localsettings.custom_jailbreak_text.replaceAll("\\n", "\n"); - } - if(force_thinking_tag && start_thinking_tag!="") - { - newgen = newgen + start_thinking_tag.replaceAll("\\n", "\n"); - } - } - else //may be continuting existing instruction OR starting a brand new session. check if first action - { - if (is_impersonate_user) { - is_impersonate_user = false; - if (localsettings.separate_end_tags) { - pending_context_preinjection = prev_et + ist; //bot response as first msg - pending_context_postinjection = iste + iet; - } else { - pending_context_preinjection = ist; //bot response as first msg - pending_context_postinjection = iet; - } - } else { - if (gametext_arr.length == 0) { - newgen = iet; - } - } - } + newgen = wrap_newgen_instruct_format(newgen,true); } if (localsettings.opmode == 3 && newgen != "") { - //append chatname for chatmode - let injecttime = ""; - if(localsettings.inject_timestamps) - { - injecttime = " ["+(new Date().toLocaleTimeString([], {year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit'}))+"]"; - } - newgen = "\n" + get_my_multiplayer_chatname() + ":"+ injecttime +" "+ newgen + ""; + newgen = wrap_newgen_chat_format(newgen); } else if(localsettings.opmode==3 && newgen.trim()=="") { @@ -15281,6 +15322,16 @@ Current version indicated by LITEVER below. if (data.id && data.id != "") { //for now, append the new image directly into the gtarr let nimgtag = "[<|p|" + data.id + "|p|>]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } gametext_arr.push(nimgtag); image_db[data.id] = { done: false, queue: "Starting", result: "", prompt:sentence, poll_category:1 }; image_db[data.id].aspect = (iwidth>=iheight*2?5:(iheight>=iwidth*2?4:(iwidth>iheight?2:(iwidth]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } gametext_arr.push(nimgtag); image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 }; image_db[imgid].aspect = (iwidth>=iheight*2?5:(iheight>=iwidth*2?4:(iwidth>iheight?2:(iwidth]"; + if (localsettings.img_newturn) { + if(localsettings.opmode == 4) + { + nimgtag = wrap_newgen_instruct_format(nimgtag,false); + } + else if(localsettings.opmode == 3) + { + nimgtag = wrap_newgen_chat_format(nimgtag); + } + } gametext_arr.push(nimgtag); image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 }; image_db[imgid].aspect = 0; @@ -20686,7 +20757,7 @@ Current version indicated by LITEVER below.
-
Search the Web for relavant information when using instruct mode
(Requires WebSearch enabled KoboldCpp)
+
Search the Web for relevant information when using instruct mode
(Requires WebSearch enabled KoboldCpp)
Enable WebSearch
@@ -21555,6 +21626,12 @@ Current version indicated by LITEVER below. :
+
+
Insert Images as New Message ? + If enabled, images will be added in a new turn message instead of the existing one. + :
+ +
@@ -22572,10 +22649,10 @@ Current version indicated by LITEVER below.