wip on multiple fixes

This commit is contained in:
Concedo 2025-03-15 10:50:36 +08:00
parent 4a29e216e7
commit 4212f0b8e8
5 changed files with 154 additions and 70 deletions

View file

@ -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()); printf("\nAttempting to apply Multimodal Projector: %s\n", mmproj_filename.c_str());
#if defined(GGML_USE_METAL) #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); set_clip_uses_gpu(false);
printf("Clip will use CPU for this model!\n"); printf("Clip will use CPU for this model!\n");

View file

@ -3159,6 +3159,7 @@ Current version indicated by LITEVER below.
img_cfgscale: 7, img_cfgscale: 7,
img_allowhd: true, img_allowhd: true,
img_crop: false, img_crop: false,
img_newturn: false,
img_img2imgstr: 0.6, img_img2imgstr: 0.6,
img_clipskip: -1, img_clipskip: -1,
img_steps: 20, img_steps: 20,
@ -3384,7 +3385,7 @@ Current version indicated by LITEVER below.
}, },
{ {
"id":14, "id":14,
"name":"KoboldCppAutoGuess", "name":"KoboldCppAutomatic",
"user":"{{[INPUT]}}", "user":"{{[INPUT]}}",
"user_end":"", "user_end":"",
"assistant":"{{[OUTPUT]}}", "assistant":"{{[OUTPUT]}}",
@ -5794,6 +5795,16 @@ Current version indicated by LITEVER below.
{ {
let imgid = resp.prompt_id.toString(); let imgid = resp.prompt_id.toString();
let nimgtag = "[<|p|" + imgid + "|p|>]"; 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); gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:prompt, poll_category:2 }; 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<req_payload.params.height?1:0)))); 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<req_payload.params.height?1:0))));
@ -6936,6 +6947,8 @@ Current version indicated by LITEVER below.
//force load everything //force load everything
import_settings(true, true, true, true, true, true); import_settings(true, true, true, true, true, true);
} }
toggle_invert_colors();
toggle_sidepanel_mode();
update_for_sidepanel(); update_for_sidepanel();
render_gametext(true); render_gametext(true);
if(!ignore_multiplayer_sync) //we don't want an infinite loop if(!ignore_multiplayer_sync) //we don't want an infinite loop
@ -8607,6 +8620,10 @@ Current version indicated by LITEVER below.
if(key && val && key.trim()!="" && val.trim()!="") if(key && val && key.trim()!="" && val.trim()!="")
{ {
let old = document.getElementById("logitbiastxtarea").value; let old = document.getElementById("logitbiastxtarea").value;
if(old.trim()=="")
{
old = "{}";
}
if(document.getElementById("newlogitbiasstringtoggle").checked) if(document.getElementById("newlogitbiasstringtoggle").checked)
{ {
kcpp_tokenize(key,(tokarr)=>{ kcpp_tokenize(key,(tokarr)=>{
@ -11072,6 +11089,7 @@ Current version indicated by LITEVER below.
document.getElementById("tokenstreammode").value = localsettings.tokenstreammode; document.getElementById("tokenstreammode").value = localsettings.tokenstreammode;
document.getElementById("img_allowhd").checked = localsettings.img_allowhd; document.getElementById("img_allowhd").checked = localsettings.img_allowhd;
document.getElementById("img_crop").checked = localsettings.img_crop; 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_autogen").checked = localsettings.img_autogen;
document.getElementById("img_gen_from_instruct").checked = localsettings.img_gen_from_instruct; document.getElementById("img_gen_from_instruct").checked = localsettings.img_gen_from_instruct;
document.getElementById("save_images").checked = localsettings.save_images; document.getElementById("save_images").checked = localsettings.save_images;
@ -11449,6 +11467,7 @@ Current version indicated by LITEVER below.
localsettings.grammar = pendinggrammar; localsettings.grammar = pendinggrammar;
localsettings.tokenstreammode = document.getElementById("tokenstreammode").value; localsettings.tokenstreammode = document.getElementById("tokenstreammode").value;
localsettings.img_crop = (document.getElementById("img_crop").checked ? true : false); 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_allowhd = (document.getElementById("img_allowhd").checked ? true : false);
localsettings.img_autogen = (document.getElementById("img_autogen").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); 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 imgid = "selfuploadimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]"; 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); gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:"", poll_category:0 }; image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:"", poll_category:0 };
image_db[imgid].aspect = 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); 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 function prepare_submit_generation() //wrap websearch into this
{ {
let senttext = document.getElementById("input_text").value; let senttext = document.getElementById("input_text").value;
@ -13536,72 +13639,10 @@ Current version indicated by LITEVER below.
if (localsettings.opmode == 4) if (localsettings.opmode == 4)
{ {
let ist = instructstartplaceholder; newgen = wrap_newgen_instruct_format(newgen,true);
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;
}
}
}
} }
if (localsettings.opmode == 3 && newgen != "") { if (localsettings.opmode == 3 && newgen != "") {
//append chatname for chatmode newgen = wrap_newgen_chat_format(newgen);
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 + "";
} }
else if(localsettings.opmode==3 && newgen.trim()=="") else if(localsettings.opmode==3 && newgen.trim()=="")
{ {
@ -15281,6 +15322,16 @@ Current version indicated by LITEVER below.
if (data.id && data.id != "") { if (data.id && data.id != "") {
//for now, append the new image directly into the gtarr //for now, append the new image directly into the gtarr
let nimgtag = "[<|p|" + data.id + "|p|>]"; 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); gametext_arr.push(nimgtag);
image_db[data.id] = { done: false, queue: "Starting", result: "", prompt:sentence, poll_category:1 }; 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<iheight?1:0)))); image_db[data.id].aspect = (iwidth>=iheight*2?5:(iheight>=iwidth*2?4:(iwidth>iheight?2:(iwidth<iheight?1:0))));
@ -15303,6 +15354,16 @@ Current version indicated by LITEVER below.
genimg_payload.models = [desired_model]; genimg_payload.models = [desired_model];
let imgid = "A1111img"+(Math.floor(10000 + Math.random() * 90000)).toString(); let imgid = "A1111img"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]"; 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); gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 }; 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<iheight?1:0)))); image_db[imgid].aspect = (iwidth>=iheight*2?5:(iheight>=iwidth*2?4:(iwidth>iheight?2:(iwidth<iheight?1:0))));
@ -15333,6 +15394,16 @@ Current version indicated by LITEVER below.
{ {
let imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString(); let imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]"; 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); gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 }; image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 };
image_db[imgid].aspect = 0; image_db[imgid].aspect = 0;
@ -20686,7 +20757,7 @@ Current version indicated by LITEVER below.
</div> </div>
<div class="context_tab_container" id="websearch_tab_container"> <div class="context_tab_container" id="websearch_tab_container">
<div class="settinglabel" style="padding: 4px;">Search the Web for relavant information when using instruct mode<br>(Requires WebSearch enabled KoboldCpp)</div> <div class="settinglabel" style="padding: 4px;">Search the Web for relevant information when using instruct mode<br>(Requires WebSearch enabled KoboldCpp)</div>
<div id="websearchunsupporteddiv" class="color_red hidden" style="font-weight:bold;padding:3px;font-size:12px">WebSearch Not Supported</div> <div id="websearchunsupporteddiv" class="color_red hidden" style="font-weight:bold;padding:3px;font-size:12px">WebSearch Not Supported</div>
<div class="settinglabel" style="padding: 4px;"> <div class="settinglabel" style="padding: 4px;">
<div class="justifyleft settingsmall" title="Enable WebSearch">Enable WebSearch </div> <div class="justifyleft settingsmall" title="Enable WebSearch">Enable WebSearch </div>
@ -21555,6 +21626,12 @@ Current version indicated by LITEVER below.
</span>: </div> </span>: </div>
<input title="Crop Images" type="checkbox" id="img_crop" style="margin:0px 0 0;"> <input title="Crop Images" type="checkbox" id="img_crop" style="margin:0px 0 0;">
</div> </div>
<div class="inlinelabel">
<div class="justifyleft rowitem">Insert Images as New Message <span class="helpicon">?
<span class="helptext">If enabled, images will be added in a new turn message instead of the existing one.</span>
</span>: </div>
<input title="Insert Images as New Message" type="checkbox" id="img_newturn" style="margin:0px 0 0;">
</div>
</div> </div>
</div> </div>
</div> </div>
@ -22572,10 +22649,10 @@ Current version indicated by LITEVER below.
<button type="button" class="btn btn-primary bg_green" onclick="add_img_btn_upload()">Upload Image File</button> <button type="button" class="btn btn-primary bg_green" onclick="add_img_btn_upload()">Upload Image File</button>
</div> </div>
<div class="menutext"> <div class="menutext">
<button type="button" class="btn btn-primary bg_green" onclick="add_img_btn_paste()">Paste from Clipboard</button> <button type="button" class="btn btn-primary bg_green" onclick="add_img_btn_paste()">Drag Drop / Paste from Clipboard</button>
</div> </div>
<div class="menutext"> <div class="menutext">
<button type="button" class="btn btn-primary" onclick="hide_popups();display_settings();display_settings_tab(2);">Customize Settings</button> <button type="button" class="btn btn-primary" onclick="hide_popups();display_settings();display_settings_tab(2);">Customize Image Settings</button>
</div> </div>
<div class="menutext hidden" id="btn_open_stableui"> <div class="menutext hidden" id="btn_open_stableui">
<button type="button" class="btn btn-primary bg_purple" onclick="go_to_stableui()">Go To StableUI</button> <button type="button" class="btn btn-primary bg_purple" onclick="go_to_stableui()">Go To StableUI</button>

View file

@ -1013,15 +1013,19 @@ def fetch_gpu_properties(testCL,testCU,testVK):
data = json.loads(output) data = json.loads(output)
plat = 0 plat = 0
dev = 0 dev = 0
lowestclmem = 0
for platform in data["devices"]: for platform in data["devices"]:
dev = 0 dev = 0
for device in platform["online"]: for device in platform["online"]:
dname = device["CL_DEVICE_NAME"] dname = device["CL_DEVICE_NAME"]
dmem = int(device["CL_DEVICE_GLOBAL_MEM_SIZE"])
idx = plat+dev*2 idx = plat+dev*2
if idx<len(CLDevices): if idx<len(CLDevices):
CLDevicesNames[idx] = dname CLDevicesNames[idx] = dname
lowestclmem = dmem if lowestclmem==0 else (dmem if dmem<lowestclmem else lowestclmem)
dev += 1 dev += 1
plat += 1 plat += 1
MaxMemory[0] = max(lowestclmem,MaxMemory[0])
except Exception: except Exception:
pass pass
return return
@ -5980,6 +5984,7 @@ if __name__ == '__main__':
advparser.add_argument("--exporttemplate", help="Exports the current selected arguments as a .kcppt template file", metavar=('[filename]'), type=str, default="") advparser.add_argument("--exporttemplate", help="Exports the current selected arguments as a .kcppt template file", metavar=('[filename]'), type=str, default="")
advparser.add_argument("--nomodel", help="Allows you to launch the GUI alone, without selecting any model.", action='store_true') advparser.add_argument("--nomodel", help="Allows you to launch the GUI alone, without selecting any model.", action='store_true')
advparser.add_argument("--moeexperts", metavar=('[num of experts]'), help="How many experts to use for MoE models (default=follow gguf)", type=int, default=-1) advparser.add_argument("--moeexperts", metavar=('[num of experts]'), help="How many experts to use for MoE models (default=follow gguf)", type=int, default=-1)
advparser.add_argument("--defaultgenamt", help="How many tokens to generate by default, if not specified. Must be smaller than context size. Usually, your frontend GUI will override this.", type=check_range(int,256,2048), default=512)
compatgroup2 = parser.add_mutually_exclusive_group() compatgroup2 = parser.add_mutually_exclusive_group()
compatgroup2.add_argument("--showgui", help="Always show the GUI instead of launching the model right away when loading settings from a .kcpps file.", action='store_true') compatgroup2.add_argument("--showgui", help="Always show the GUI instead of launching the model right away when loading settings from a .kcpps file.", action='store_true')
compatgroup2.add_argument("--skiplauncher", help="Doesn't display or use the GUI launcher.", action='store_true') compatgroup2.add_argument("--skiplauncher", help="Doesn't display or use the GUI launcher.", action='store_true')

View file

@ -50,6 +50,7 @@ int main(void) {
unsigned number; unsigned number;
cl_device_type type; cl_device_type type;
char name[128]; char name[128];
cl_ulong global_mem_size;
}; };
enum { NPLAT = 16, NDEV = 16 }; enum { NPLAT = 16, NDEV = 16 };
@ -94,7 +95,8 @@ int main(void) {
d->platform = p; d->platform = p;
CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_NAME, sizeof(d->name), &d->name, NULL)); CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_NAME, sizeof(d->name), &d->name, NULL));
CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_TYPE, sizeof(d->type), &d->type, NULL)); CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_TYPE, sizeof(d->type), &d->type, NULL));
std::string devicetemplate = "{\"CL_DEVICE_NAME\":\"" + std::string(d->name) + "\"}"; CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(d->global_mem_size), &d->global_mem_size, NULL));
std::string devicetemplate = "{\"CL_DEVICE_NAME\":\"" + std::string(d->name) + "\", \"CL_DEVICE_GLOBAL_MEM_SIZE\":"+std::to_string(d->global_mem_size)+"}";
if(j>0) if(j>0)
{ {
devicetemplate = ","+devicetemplate; devicetemplate = ","+devicetemplate;

Binary file not shown.