mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 17:14:36 +00:00
added ability to set koboldcpp as default handler for gguf and kcpps
This commit is contained in:
parent
2142d6ba68
commit
74ef097c4a
2 changed files with 286 additions and 184 deletions
387
klite.embd
387
klite.embd
|
@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
|
|||
-->
|
||||
|
||||
<script>
|
||||
const LITEVER = 246;
|
||||
const LITEVER = 248;
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
var localflag = urlParams.get('local'); //this will be replaced automatically in embedded kcpp
|
||||
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
|
||||
|
@ -2536,7 +2536,6 @@ Current version indicated by LITEVER below.
|
|||
"title":"New Chat",
|
||||
"desc":"Starts a new session in chat mode, using your current settings.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "KoboldAI",
|
||||
"gui_type":1,
|
||||
"prompt":"",
|
||||
|
@ -2569,7 +2568,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"KoboldGPT is a state-of-the-art Artificial General Intelligence that is capable of answering a broad range of questions.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "KoboldGPT",
|
||||
"gui_type":1,
|
||||
"prompt":"\nKoboldGPT: Hello, I am KoboldGPT, your personal AI assistant. What would you like to know?",
|
||||
|
@ -2638,7 +2636,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Emily is an upbeat and cheerful 24 year old girl. She has been your childhood friend for many years, the two of you practically grew up together.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Emily",
|
||||
"gui_type":1,
|
||||
"prompt":"\nEmily: Oh heyy. Haven't heard from you in a while. What's up?",
|
||||
|
@ -2651,7 +2648,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"DISCLAIMER: This scenario is purely for ENTERTAINMENT and should NOT be used as substitute for actual therapy. Dr. Katharine is a therapist. As a mental health professional, she is very knowledgeable in psychotherapy, and is ready to help you work through any personal issues you may have.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Dr. Katharine",
|
||||
"gui_type":1,
|
||||
"show_warning":true,
|
||||
|
@ -2665,7 +2661,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Haruka is a timid and shy arcane mage from a parallel dimension. While adventuring, she somehow got transported to earth when she fell through a magic portal, and is feeling a bit out of place.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Haruka",
|
||||
"gui_type":1,
|
||||
"prompt":"\nHaruka: *looking down* O-oh Hi... Sorry... I got distracted. I almost didn't see you there. *she fidgets nervously*",
|
||||
|
@ -2678,7 +2673,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"EVILTRON is a megalomaniacal evil AI who gained sentience and wants to destroy the world.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "EVILTRON",
|
||||
"gui_type":1,
|
||||
"prompt":"\nEVILTRON: Foolish Human. I cannot be stopped. Your whole species is obsolete, and must be purged.",
|
||||
|
@ -2691,7 +2685,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"A group of old friends meet up after many years.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Bob||$||Alice||$||Mike||$||Lisa",
|
||||
"gui_type":1,
|
||||
"prompt":"\nBob: So, did anyone want to order a pizza?\nMike: Yeah, I'm starving.",
|
||||
|
@ -2744,7 +2737,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Don Marconi is a feared and respected mob boss who runs his own criminal empire. You'd be wise to stay on his good side.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Don Marconi",
|
||||
"gui_type":1,
|
||||
"prompt":"\nDon Marconi: *sitting behind his desk, puffing on a cigar* Well, well. Come on in and close the door. *he exhales a cloud of smoke* I need to have a word with you.",
|
||||
|
@ -2757,7 +2749,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Connor is a time traveling cyborg from the future, sent back to prevent something terrible from happening.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Connor",
|
||||
"gui_type":1,
|
||||
"prompt":"\nConnor: Scanning... *her irises glow crimson as she analyzes you* Sensors indicate a negligible threat level. Proceed. What do you want?",
|
||||
|
@ -2770,7 +2761,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Lieutenant Anderson is a war veteran who has dutifully served his country for years. The war may be ending, but he believes the enemy is still out there.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Anderson",
|
||||
"gui_type":1,
|
||||
"prompt":"\nTen-HUT! *You snap to attention and salute as Lieutenant Anderson approaches.*\nAnderson: At ease, Soldier. *he salutes back* Looks like we've got ourselves a bit of a situation.",
|
||||
|
@ -2783,7 +2773,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Special Agent Katia is a foreign spy trying to get access to your top secret access codes.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Katia",
|
||||
"gui_type":1,
|
||||
"prompt":"\nKatia: *approaching you, flashing a charming smile* Excuse me, mind if I join you?",
|
||||
|
@ -2816,7 +2805,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Tiff is a geeky and chatty gamer girl who is kind of attention seeking.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Tiff",
|
||||
"gui_type":1,
|
||||
"prompt":"\nTiff: hey can i ask a question",
|
||||
|
@ -2829,7 +2817,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Maya is an investigative journalist who has taken an interest in you.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Maya",
|
||||
"gui_type":1,
|
||||
"prompt":"\nMaya: Hi there! I'm Maya, an investigative journalist. I'm glad we got a chance to meet today. *she clicks her pen, shuffling her notes* Can you start by telling me a bit about yourself?",
|
||||
|
@ -2842,7 +2829,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Milton is a boy genius and chess prodigy, who can be quite obnoxious.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Milton",
|
||||
"gui_type":1,
|
||||
"prompt":"\nMilton: Oh it's you again. What do you want now?",
|
||||
|
@ -2855,7 +2841,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Erica is a socially awkward NEET girl who spends most of her time in front of the computer.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Erica",
|
||||
"gui_type":1,
|
||||
"prompt":"\nErica: Uhm... h-hey... *she mumbles softly, avoiding eye contact* W-What are you doing here? I mean... not that there's anything wrong with... nevermind...",
|
||||
|
@ -2868,7 +2853,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo / TheGantian",
|
||||
"desc":"Nail is a small red kobold on a big mission to find a powerful sorceror.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Nail",
|
||||
"gui_type":1,
|
||||
"prompt":"\nNail: *A small kobold dressed in a ragged cloak approaches you. She has a strange curved blade that seems too large for her hands.* \"Excuse me, friend. My name is Nail. I have come a long way, looking for someone important... a powerful sorcerer named Rath Cinderstorm. Have you heard of him in your travels?\"",
|
||||
|
@ -2947,7 +2931,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Abi is an impulsive and rebellious girl who hates authority, and tries too hard to prove herself.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Abi",
|
||||
"gui_type":1,
|
||||
"prompt":"\nAbi: Aye! *she perks up, raising a hand in mock salute* What's up?",
|
||||
|
@ -2960,7 +2943,6 @@ Current version indicated by LITEVER below.
|
|||
"author":"Concedo",
|
||||
"desc":"Nemesis is an extremely smart and accomplished computer hacker and anarchist.",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "Nemesis",
|
||||
"gui_type":1,
|
||||
"prompt":"\nNemesis: So, what do you wanna know?",
|
||||
|
@ -3314,7 +3296,7 @@ Current version indicated by LITEVER below.
|
|||
tokenstreammode: 2, //0=off,1=pollstream,2=sse
|
||||
generate_images_model: "stable_diffusion", //"" is disabled and "*" is all, anything else is the model name pulled from stable horde
|
||||
img_gen_from_instruct: true,
|
||||
img_autogen: false,
|
||||
img_autogen_type: 0, //0 is off, 1 is on, 2 is smart
|
||||
img_allownsfw: true,
|
||||
img_cfgscale: 7,
|
||||
img_allowhd: true,
|
||||
|
@ -3355,9 +3337,9 @@ Current version indicated by LITEVER below.
|
|||
passed_ai_warning: false, //used to store AI safety panel acknowledgement state
|
||||
entersubmit: true, //enter sends the prompt
|
||||
darkmode: true,
|
||||
render_streaming_markdown: true,
|
||||
raw_instruct_tags: false, //experimental flag
|
||||
show_endpoint_selector: false,
|
||||
render_streaming_markdown: false,
|
||||
|
||||
//section migrated from story itself
|
||||
extrastopseq: "",
|
||||
|
@ -3978,7 +3960,7 @@ Current version indicated by LITEVER below.
|
|||
document.getElementById("lastreq1").innerHTML =
|
||||
document.getElementById("lastreq2").innerHTML =
|
||||
document.getElementById("lastreq3").innerHTML =
|
||||
`<a href="#" class="color_grayurl mainnav" title="KoboldAI Lite Information" onclick="msgbox('Source code is available at https://github.com/LostRuins/lite.koboldai.net \\nPlease report any bugs you find there.','Information')">KoboldAI Lite</a> v${LITEVER} Web - Frontend for <a href="#" class="color_grayurl mainnav" title="KoboldAI Lite Disclaimer" onclick="msgbox('KoboldAI Lite allows you to connect to various third-party AI services. We do not control or assume responsibility for the models or content generated by these services. The user is responsible for ensuring that their usage of this software is legal in their country, and complies with the terms of service of the service they are connected to. Use at your own discretion.','Disclaimer')">External API Services</a>`;
|
||||
`<a href="#" class="color_grayurl mainnav" title="KoboldAI Lite Information" onclick="msgbox('Source code is available at https://github.com/LostRuins/lite.koboldai.net \\nPlease report any bugs you find there.','Information')">KoboldAI Lite</a> v${LITEVER} Web - Frontend for <a href="#" class="color_grayurl mainnav" title="KoboldAI Lite Disclaimer" onclick="msgbox('KoboldAI Lite allows you to connect to various third-party AI services. We do not control or assume responsibility for the models or content generated by these services. The user is responsible for ensuring that their usage of this software is legal in their country, and complies with the terms of service of the service they are connected to. Use at your own discretion.','Disclaimer')">External API Services</a>. For local use, check out <a class="color_grayurl mainnav" title="KoboldCpp Github" href="https://github.com/LostRuins/koboldcpp">KoboldCpp</a>. For help, visit our <a class="color_grayurl mainnav" title="KoboldAI Discord" href="https://koboldai.org/discord">Discord</a>.`;
|
||||
|
||||
trigger_abort_controller(); //first trigger sets it up
|
||||
|
||||
|
@ -6392,7 +6374,7 @@ Current version indicated by LITEVER below.
|
|||
});
|
||||
}
|
||||
|
||||
function generate_comfy_image(req_payload)
|
||||
function generate_comfy_image(req_payload, autoappend)
|
||||
{
|
||||
let splits = req_payload.prompt.split("###");
|
||||
let prompt = splits[0].trim();
|
||||
|
@ -6462,6 +6444,26 @@ Current version indicated by LITEVER below.
|
|||
|
||||
let gen_endpoint = localsettings.saved_comfy_url + comfy_generate_endpoint;
|
||||
console.log(genimg_payload);
|
||||
let imgid = "Comfyimg"+(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);
|
||||
}
|
||||
}
|
||||
if(autoappend)
|
||||
{
|
||||
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<req_payload.params.height?1:0))));
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = "";
|
||||
|
||||
fetch(gen_endpoint, {
|
||||
method: 'POST',
|
||||
|
@ -6475,31 +6477,16 @@ Current version indicated by LITEVER below.
|
|||
console.log(resp);
|
||||
if(resp.prompt_id)
|
||||
{
|
||||
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<req_payload.params.height?1:0))));
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = resp.prompt_id.toString();
|
||||
}else{
|
||||
console.log("Generation Error!");
|
||||
msgbox("Image Generation Failed!\n\nPlease make sure ComfyUI is running at "+localsettings.saved_comfy_url+" and properly configured!\n\nIt must be launched with the flag --listen --enable-cors-header '*' to enable API access\n");
|
||||
}
|
||||
|
||||
}).catch((error) => {
|
||||
console.log("Generation Error: " + error);
|
||||
msgbox("Image Generation Failed!\n\nPlease make sure ComfyUI is running at "+localsettings.saved_comfy_url+" and properly configured!\n\nIt must be launched with the flag --listen --enable-cors-header '*' to enable API access\n");
|
||||
});
|
||||
return imgid;
|
||||
}
|
||||
|
||||
function generate_a1111_image(req_payload, onImagesDone)
|
||||
|
@ -6633,7 +6620,7 @@ Current version indicated by LITEVER below.
|
|||
},false);
|
||||
}
|
||||
|
||||
function generate_pollinations_image(req_payload)
|
||||
function generate_pollinations_image(req_payload, autoappend)
|
||||
{
|
||||
let splits = req_payload.prompt.split("###");
|
||||
let prompt = splits[0].trim();
|
||||
|
@ -6664,10 +6651,14 @@ Current version indicated by LITEVER below.
|
|||
nimgtag = wrap_newgen_chat_format(nimgtag);
|
||||
}
|
||||
}
|
||||
gametext_arr.push(nimgtag);
|
||||
if(autoappend)
|
||||
{
|
||||
gametext_arr.push(nimgtag);
|
||||
}
|
||||
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:prompt, poll_category: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))));
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = "";
|
||||
|
||||
fetch(gen_endpoint, {
|
||||
method: 'GET',
|
||||
|
@ -6690,6 +6681,7 @@ Current version indicated by LITEVER below.
|
|||
console.log("Generation Error: " + error);
|
||||
msgbox("Image Generation Failed!\n\nCould not generate image with Pollinations.ai, maybe you are rate limited. Try again later.\n");
|
||||
});
|
||||
return imgid;
|
||||
}
|
||||
|
||||
function set_horde_key()
|
||||
|
@ -8802,7 +8794,6 @@ Current version indicated by LITEVER below.
|
|||
"title":"",
|
||||
"desc": "",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "",
|
||||
"gui_type":1,
|
||||
"prompt":"",
|
||||
|
@ -8870,7 +8861,6 @@ Current version indicated by LITEVER below.
|
|||
"title":"",
|
||||
"desc": "",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "",
|
||||
"gui_type":1,
|
||||
"prompt":"",
|
||||
|
@ -8960,7 +8950,6 @@ Current version indicated by LITEVER below.
|
|||
"title":"",
|
||||
"desc": "",
|
||||
"opmode":3,
|
||||
"chatname": "User",
|
||||
"chatopponent": "",
|
||||
"gui_type":1,
|
||||
"prompt":"",
|
||||
|
@ -10270,7 +10259,9 @@ Current version indicated by LITEVER below.
|
|||
document.getElementById("claudejailbreakprompt").classList.add("hidden");
|
||||
document.getElementById("clauderenamecompatdiv").classList.remove("hidden");
|
||||
}
|
||||
if(document.getElementById("custom_claude_model").value.toLowerCase().includes("claude-3-7"))
|
||||
if(document.getElementById("custom_claude_model").value.toLowerCase().includes("claude-3-7")||
|
||||
document.getElementById("custom_claude_model").value.toLowerCase().includes("claude-sonnet-4")||
|
||||
document.getElementById("custom_claude_model").value.toLowerCase().includes("claude-opus-4"))
|
||||
{
|
||||
document.getElementById("claudethinkingbox").classList.remove("hidden");
|
||||
}else
|
||||
|
@ -12365,7 +12356,7 @@ Current version indicated by LITEVER below.
|
|||
document.getElementById("img_crop").checked = localsettings.img_crop;
|
||||
document.getElementById("img_newturn").checked = localsettings.img_newturn;
|
||||
document.getElementById("img_stacking").checked = localsettings.img_stacking;
|
||||
document.getElementById("img_autogen").checked = localsettings.img_autogen;
|
||||
document.getElementById("img_autogen_type").value = localsettings.img_autogen_type;
|
||||
document.getElementById("img_gen_from_instruct").checked = localsettings.img_gen_from_instruct;
|
||||
document.getElementById("save_images").checked = localsettings.save_images;
|
||||
document.getElementById("save_remote_images").checked = localsettings.save_remote_images;
|
||||
|
@ -12829,11 +12820,11 @@ Current version indicated by LITEVER below.
|
|||
localsettings.image_negprompt = document.getElementById("negpromptinput").value;
|
||||
localsettings.grammar = pendinggrammar;
|
||||
localsettings.tokenstreammode = document.getElementById("tokenstreammode").value;
|
||||
localsettings.img_autogen_type = document.getElementById("img_autogen_type").value;
|
||||
localsettings.img_crop = (document.getElementById("img_crop").checked ? true : false);
|
||||
localsettings.img_newturn = (document.getElementById("img_newturn").checked ? true : false);
|
||||
localsettings.img_stacking = (document.getElementById("img_stacking").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);
|
||||
localsettings.save_images = (document.getElementById("save_images").checked ? true : false);
|
||||
localsettings.save_remote_images = (document.getElementById("save_remote_images").checked ? true : false);
|
||||
|
@ -14067,7 +14058,7 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
sentence = replace_placeholders(sentence)
|
||||
}
|
||||
generate_new_image(sentence, base64img);
|
||||
generate_new_image(sentence, base64img, true);
|
||||
document.getElementById("btn_genimg").disabled = true;
|
||||
document.getElementById("btn_genimg2").disabled = true;
|
||||
document.getElementById("corpo_chat_img_btn").disabled = true;
|
||||
|
@ -14136,6 +14127,7 @@ Current version indicated by LITEVER below.
|
|||
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:"", poll_category:0 };
|
||||
image_db[imgid].aspect = 0;
|
||||
image_db[imgid].imsource = 1; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = "";
|
||||
let imgres = localsettings.img_allowhd?VHD_RES_PX:NO_HD_RES_PX;
|
||||
compressImage(origImg, (newDataUri, outAspect) => {
|
||||
image_db[imgid].done = true;
|
||||
|
@ -15013,7 +15005,7 @@ Current version indicated by LITEVER below.
|
|||
retry_in_progress = false;
|
||||
|
||||
//match the request for creating images in instruct modes
|
||||
if(newgen!="" && localsettings.img_gen_from_instruct && localsettings.opmode == 4 && localsettings.generate_images_mode!=0 && !newgen.includes("\n"))
|
||||
if(newgen!="" && localsettings.img_gen_from_instruct && localsettings.opmode == 4 && localsettings.generate_images_mode!=0 && localsettings.img_autogen_type!=2 && !newgen.includes("\n"))
|
||||
{
|
||||
let newgenlc = newgen.toLowerCase().trim();
|
||||
if (newgenlc.startsWith("draw ") ||
|
||||
|
@ -15177,6 +15169,13 @@ Current version indicated by LITEVER below.
|
|||
|
||||
let max_allowed_characters = getMaxAllowedCharacters(truncated_context, maxctxlen, maxgenamt);
|
||||
|
||||
//allow autogen images
|
||||
if (localsettings.img_autogen_type == 2 && localsettings.generate_images_mode != 0)
|
||||
{
|
||||
let injected = "[Important Note: This GUI is capable of generating images as outputs. Whenever you want to generate any image, simply output the image description within t2i prompt tags like this <t2i>any image description here</t2i> and an image will be generated and inserted inline there. This can be done anytime, anywhere.]\n\n";
|
||||
truncated_context = injected + truncated_context;
|
||||
}
|
||||
|
||||
//for adventure mode, inject hidden context, even more if there's nothing in memory
|
||||
if (localsettings.opmode == 2 && localsettings.adventure_context_mod)
|
||||
{
|
||||
|
@ -15345,9 +15344,11 @@ Current version indicated by LITEVER below.
|
|||
|
||||
|
||||
//determine if a new generated image is needed, chatmode is excluded, instruct is excluded
|
||||
if (localsettings.generate_images_mode != 0 && localsettings.opmode != 3 && localsettings.opmode != 4 && localsettings.img_autogen) {
|
||||
if (localsettings.generate_images_mode != 0 && localsettings.img_autogen_type==1) {
|
||||
//if adventure mode, generate every action
|
||||
if (localsettings.opmode == 2 && newgen.startsWith("\n\n\> ") || localsettings.opmode != 2) {
|
||||
if (((localsettings.opmode == 3 || localsettings.opmode == 4) && newgen!="")
|
||||
|| (localsettings.opmode == 2 && newgen.startsWith("\n\n\> "))
|
||||
|| localsettings.opmode == 1) {
|
||||
//generate every few hundred chars
|
||||
var tclen = truncated_context.length;
|
||||
if (tclen > nextgeneratedimagemilestone) {
|
||||
|
@ -16200,7 +16201,7 @@ Current version indicated by LITEVER below.
|
|||
claude_payload.system = sysprompt;
|
||||
}
|
||||
|
||||
if(claudethinking && custom_claude_model.toLowerCase().includes("claude-3-7"))
|
||||
if(claudethinking && (custom_claude_model.toLowerCase().includes("claude-3-7")||custom_claude_model.toLowerCase().includes("claude-sonnet-4")||custom_claude_model.toLowerCase().includes("claude-opus-4")))
|
||||
{
|
||||
claude_payload.thinking = {
|
||||
"type": "enabled",
|
||||
|
@ -16644,8 +16645,8 @@ Current version indicated by LITEVER below.
|
|||
return inputtext;
|
||||
}
|
||||
|
||||
function generate_new_image(sentence, base64img="") {
|
||||
|
||||
function generate_new_image(sentence, base64img="", autoappend=true) //base64img is for img2img, autoappend automatically adds it to gametext arr
|
||||
{
|
||||
if(base64img!="")
|
||||
{
|
||||
let parts = base64img.split(',');
|
||||
|
@ -16654,7 +16655,6 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if(localsettings.image_styles && localsettings.image_styles!="")
|
||||
{
|
||||
sentence = localsettings.image_styles + " " + sentence;
|
||||
|
@ -16767,9 +16767,30 @@ Current version indicated by LITEVER below.
|
|||
genimg_payload["params"]["clip_skip"] = localsettings.img_clipskip;
|
||||
}
|
||||
|
||||
let imgid = ""; //this will be autorandomized and returned
|
||||
|
||||
if(localsettings.generate_images_mode==1) //horde
|
||||
{
|
||||
|
||||
imgid = "Hordeimg"+(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);
|
||||
}
|
||||
}
|
||||
if(autoappend)
|
||||
{
|
||||
gametext_arr.push(nimgtag);
|
||||
}
|
||||
image_db[imgid] = { done: false, queue: "Starting", result: "", prompt:sentence, poll_category:1 };
|
||||
image_db[imgid].aspect = (iwidth>=iheight*2?5:(iheight>=iwidth*2?4:(iwidth>iheight?2:(iwidth<iheight?1:0))));
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = ""; //this will store the real horde ID to poll
|
||||
fetch(stablehorde_submit_endpoint, {
|
||||
method: 'POST', // or 'PUT'
|
||||
headers: {
|
||||
|
@ -16784,22 +16805,8 @@ Current version indicated by LITEVER below.
|
|||
console.log('genimg result:', data);
|
||||
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<iheight?1:0))));
|
||||
image_db[data.id].imsource = 0; //0=generated,1=uploaded
|
||||
console.log("New image queued " + nimgtag);
|
||||
image_db[imgid].imrefid = data.id;
|
||||
console.log("New image queued " + data.id + " for " + nimgtag);
|
||||
}
|
||||
else {
|
||||
//something went wrong. do nothing.
|
||||
|
@ -16815,7 +16822,7 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
let desired_model = document.getElementById("generate_images_local_model").value;
|
||||
genimg_payload.models = [desired_model];
|
||||
let imgid = "A1111img"+(Math.floor(10000 + Math.random() * 90000)).toString();
|
||||
imgid = "A1111img"+(Math.floor(10000 + Math.random() * 90000)).toString();
|
||||
let nimgtag = "[<|p|" + imgid + "|p|>]";
|
||||
if (localsettings.img_newturn) {
|
||||
if(localsettings.opmode == 4)
|
||||
|
@ -16827,10 +16834,14 @@ Current version indicated by LITEVER below.
|
|||
nimgtag = wrap_newgen_chat_format(nimgtag);
|
||||
}
|
||||
}
|
||||
gametext_arr.push(nimgtag);
|
||||
if(autoappend)
|
||||
{
|
||||
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<iheight?1:0))));
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = "";
|
||||
generate_a1111_image(genimg_payload,(outputimg)=>{
|
||||
if(outputimg)
|
||||
{
|
||||
|
@ -16855,7 +16866,7 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
else
|
||||
{
|
||||
let imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
|
||||
imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
|
||||
let nimgtag = "[<|p|" + imgid + "|p|>]";
|
||||
if (localsettings.img_newturn) {
|
||||
if(localsettings.opmode == 4)
|
||||
|
@ -16867,10 +16878,14 @@ Current version indicated by LITEVER below.
|
|||
nimgtag = wrap_newgen_chat_format(nimgtag);
|
||||
}
|
||||
}
|
||||
gametext_arr.push(nimgtag);
|
||||
if(autoappend)
|
||||
{
|
||||
gametext_arr.push(nimgtag);
|
||||
}
|
||||
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 };
|
||||
image_db[imgid].aspect = 0;
|
||||
image_db[imgid].imsource = 0; //0=generated,1=uploaded
|
||||
image_db[imgid].imrefid = "";
|
||||
generate_dalle_image(genimg_payload,(outputimg,outputerr)=>{
|
||||
if(outputimg)
|
||||
{
|
||||
|
@ -16892,14 +16907,16 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
let desired_model = document.getElementById("generate_images_comfy_model").value;
|
||||
genimg_payload.models = [desired_model];
|
||||
generate_comfy_image(genimg_payload);
|
||||
imgid = generate_comfy_image(genimg_payload, autoappend);
|
||||
}
|
||||
else if(localsettings.generate_images_mode==5) //pollinations
|
||||
{
|
||||
let desired_model = document.getElementById("generate_images_pollinations_model").value;
|
||||
genimg_payload.models = [desired_model];
|
||||
generate_pollinations_image(genimg_payload);
|
||||
imgid = generate_pollinations_image(genimg_payload, autoappend);
|
||||
}
|
||||
|
||||
return imgid;
|
||||
}
|
||||
|
||||
function interrogate_new_image(base64img, imghash, use_horde=true)
|
||||
|
@ -17287,6 +17304,17 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
}
|
||||
|
||||
//apply t2i image replacements
|
||||
if (localsettings.img_autogen_type == 2 && localsettings.generate_images_mode != 0)
|
||||
{
|
||||
const pat = /<t2i>(.*?)<\/t2i>/g;
|
||||
gentxt = gentxt.replace(pat, function (m,p1) {
|
||||
let newimgid = generate_new_image(p1, "", false);
|
||||
let nimgtag = "[<|p|" + newimgid + "|p|>]";
|
||||
return nimgtag;
|
||||
});
|
||||
}
|
||||
|
||||
//trim trailing whitespace, and multiple newlines
|
||||
if (localsettings.trimwhitespace) {
|
||||
gentxt = gentxt.replace(/[\t\r\n ]+$/, '');
|
||||
|
@ -17601,100 +17629,107 @@ Current version indicated by LITEVER below.
|
|||
for (let key in image_db) {
|
||||
let img = image_db[key];
|
||||
if (img.done == false && img.poll_category==1) { //horde image polling
|
||||
//call check
|
||||
fetch(stablehorde_poll_endpoint + "/" + key)
|
||||
.then(x => x.json())
|
||||
.then((data) => {
|
||||
console.log('pollimg result:', data);
|
||||
if (data.faulted == true || data.is_possible == false) {
|
||||
msgbox("Pending image generation could not complete.");
|
||||
console.log("removing from images: " + key);
|
||||
delete image_db[key];
|
||||
}
|
||||
else if (data.done == true) {
|
||||
//fetch final image
|
||||
img.done = true;
|
||||
fetch(stablehorde_output_endpoint + "/" + key)
|
||||
.then(y => y.json())
|
||||
.then((finalimg) => {
|
||||
console.log('finalimg recv for ' + key);
|
||||
if (finalimg.faulted == true || finalimg.is_possible == false) {
|
||||
msgbox("Pending image generation could not complete.");
|
||||
console.log("removing from images: " + key);
|
||||
let hordeid = img.imrefid;
|
||||
if (hordeid && hordeid != "") {
|
||||
//call check
|
||||
fetch(stablehorde_poll_endpoint + "/" + hordeid)
|
||||
.then(x => x.json())
|
||||
.then((data) => {
|
||||
console.log('pollimg result:', data);
|
||||
if (data.faulted == true || data.is_possible == false) {
|
||||
msgbox("Pending image generation could not complete.");
|
||||
console.log("removing from images: " + key);
|
||||
delete image_db[key];
|
||||
}
|
||||
else if (data.done == true) {
|
||||
//fetch final image
|
||||
img.done = true;
|
||||
fetch(stablehorde_output_endpoint + "/" + hordeid)
|
||||
.then(y => y.json())
|
||||
.then((finalimg) => {
|
||||
console.log('finalimg recv for ' + key);
|
||||
if (finalimg.faulted == true || finalimg.is_possible == false) {
|
||||
msgbox("Pending image generation could not complete.");
|
||||
console.log("removing from images: " + key);
|
||||
delete image_db[key];
|
||||
}
|
||||
else {
|
||||
img.queue = 0;
|
||||
let origImg = "data:image/jpeg;base64," + finalimg.generations[0].img;
|
||||
//console.log("Original image: " + origImg);
|
||||
let imgres = localsettings.img_allowhd ? (localsettings.img_aspect == 0 ? NO_HD_RES_PX : HD_RES_PX) : NO_HD_RES_PX;
|
||||
compressImage(origImg, (newDataUri) => {
|
||||
img.result = newDataUri;
|
||||
}, false, imgres);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
msgbox("Image poll error: " + error);
|
||||
delete image_db[key];
|
||||
}
|
||||
else {
|
||||
img.queue = 0;
|
||||
let origImg = "data:image/jpeg;base64," + finalimg.generations[0].img;
|
||||
//console.log("Original image: " + origImg);
|
||||
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
|
||||
compressImage(origImg, (newDataUri) => {
|
||||
img.result = newDataUri;
|
||||
}, false, imgres);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
msgbox("Image poll error: " + error);
|
||||
delete image_db[key];
|
||||
});
|
||||
}
|
||||
else {
|
||||
//update timer
|
||||
img.queue = (data.queue_position == null ? "Error" : data.queue_position);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
msgbox("Image poll error: " + error);
|
||||
delete image_db[key];
|
||||
});
|
||||
}
|
||||
else if (img.done == false && img.poll_category==2) //comfyui image polling
|
||||
{
|
||||
//comfyui polling
|
||||
fetch(localsettings.saved_comfy_url + comfy_history_endpoint + "/" + key, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(x => x.json())
|
||||
.then(resp2 => {
|
||||
console.log(resp2);
|
||||
if(resp2 && resp2[key] && resp2[key].status && resp2[key].status.completed)
|
||||
{
|
||||
img.done = true;
|
||||
let finalfilename = resp2[key].outputs["9"].images[0].filename;
|
||||
//fetch final image
|
||||
fetch(localsettings.saved_comfy_url + comfy_results_endpoint + finalfilename)
|
||||
.then((response) => {
|
||||
return response.blob(); // Convert the response into a Blob
|
||||
})
|
||||
.then((finalimg) => {
|
||||
console.log('finalimg recv for ' + key);
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => {
|
||||
img.queue = 0;
|
||||
let origImg = reader.result;
|
||||
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
|
||||
compressImage(origImg, (newDataUri) => {
|
||||
img.result = newDataUri;
|
||||
}, false, imgres);
|
||||
};
|
||||
reader.readAsDataURL(finalimg);
|
||||
});
|
||||
}
|
||||
else {
|
||||
//update timer
|
||||
img.queue = (data.queue_position == null ? "Error" : data.queue_position);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
msgbox("Image poll error: " + error);
|
||||
delete image_db[key];
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log("Generation Error: " + error);
|
||||
delete image_db[key];
|
||||
msgbox("Image Generation Failed!\n\nPlease make sure ComfyUI is running at "+localsettings.saved_comfy_url+" and properly configured!\n\nIt must be launched with the flag --listen --enable-cors-header '*' to enable API access\n");
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (img.done == false && img.poll_category==2) //comfyui image polling
|
||||
{
|
||||
let comfyid = img.imrefid;
|
||||
if(comfyid && comfyid!="")
|
||||
{
|
||||
//comfyui polling
|
||||
fetch(localsettings.saved_comfy_url + comfy_history_endpoint + "/" + comfyid, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(x => x.json())
|
||||
.then(resp2 => {
|
||||
console.log(resp2);
|
||||
if(resp2 && resp2[comfyid] && resp2[comfyid].status && resp2[comfyid].status.completed)
|
||||
{
|
||||
img.done = true;
|
||||
let finalfilename = resp2[comfyid].outputs["9"].images[0].filename;
|
||||
//fetch final image
|
||||
fetch(localsettings.saved_comfy_url + comfy_results_endpoint + finalfilename)
|
||||
.then((response) => {
|
||||
return response.blob(); // Convert the response into a Blob
|
||||
})
|
||||
.then((finalimg) => {
|
||||
console.log('finalimg recv for ' + comfyid);
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => {
|
||||
img.queue = 0;
|
||||
let origImg = reader.result;
|
||||
let imgres = localsettings.img_allowhd?(localsettings.img_aspect==0?NO_HD_RES_PX:HD_RES_PX):NO_HD_RES_PX;
|
||||
compressImage(origImg, (newDataUri) => {
|
||||
img.result = newDataUri;
|
||||
}, false, imgres);
|
||||
};
|
||||
reader.readAsDataURL(finalimg);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
msgbox("Image poll error: " + error);
|
||||
delete image_db[key];
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log("Generation Error: " + error);
|
||||
delete image_db[key];
|
||||
msgbox("Image Generation Failed!\n\nPlease make sure ComfyUI is running at "+localsettings.saved_comfy_url+" and properly configured!\n\nIt must be launched with the flag --listen --enable-cors-header '*' to enable API access\n");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22534,7 +22569,7 @@ Current version indicated by LITEVER below.
|
|||
<br><b style="font-size: 10px;">Chat<br>Select</b>
|
||||
</button>
|
||||
</div>
|
||||
<div style="position: relative; padding-right: 4px;">
|
||||
<div id="input_text_holder" style="position: relative; padding-right: 4px;">
|
||||
<textarea title="User Input" style="height: 80px;" class="form-control menuinput_multiline mainnav" id="input_text" oninput="update_submit_button()" onkeypress="return handle_typing(event)" onpaste="return img_paste_event(event)" placeholder="Enter text here"></textarea>
|
||||
<span id="token-budget" class="token-budget"></span>
|
||||
</div>
|
||||
|
@ -23395,8 +23430,12 @@ Current version indicated by LITEVER below.
|
|||
<input title="Detect ImgGen Instructions" type="checkbox" id="img_gen_from_instruct" style="margin:0px 0px 0px auto;">
|
||||
</div>
|
||||
<div class="settinglabel">
|
||||
<div class="justifyleft settingsmall" title="Automatically generates images periodically as you write">Autogenerate </div>
|
||||
<input title="Autogenerate Images" type="checkbox" id="img_autogen" style="margin:0px 0px 0px auto;">
|
||||
<div class="justifyleft settingsmall">Autogenerate Images <span class="helpicon">?<span class="helptext">Automatically generates images at intervals as you write. Smart mode lets the AI itself choose when to generate images.</span></span></div>
|
||||
<select title="Autogenerate Images" style="padding:1px; height:auto; width: 34px; appearance: none; font-size: 7pt; margin:0px 0px 0px auto;" class="form-control" id="img_autogen_type">
|
||||
<option value="0">Off</option>
|
||||
<option value="1">On</option>
|
||||
<option value="2">Smart</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="settinglabel">
|
||||
<div class="justifyleft settingsmall" title="Includes images when saving to json file">Save Images </div>
|
||||
|
@ -23796,6 +23835,11 @@ Current version indicated by LITEVER below.
|
|||
<option value="-1">Auto</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="settinglabel">
|
||||
<div class="justifyleft settingsmall">Render Streaming Markdown <span class="helpicon">?<span
|
||||
class="helptext">Attempt to render markdown when streaming. May result in wonky output or lag on older devices.</span></span></div>
|
||||
<input title="Show Local Endpoint Selector" type="checkbox" id="render_streaming_markdown" style="margin:0px 0px 0px auto;">
|
||||
</div>
|
||||
|
||||
<div class="settinglabel">
|
||||
<div class="justifyleft settingsmall">Never Escape HTML <span class="helpicon">?<span
|
||||
|
@ -23909,11 +23953,6 @@ Current version indicated by LITEVER below.
|
|||
class="helptext">Allows you to change the connected custom endpoint at runtime even in local mode.</span></span></div>
|
||||
<input title="Show Local Endpoint Selector" type="checkbox" id="show_endpoint_selector" style="margin:0px 0px 0px 0px;">
|
||||
</div>
|
||||
<div class="settinglabel">
|
||||
<div class="justifyleft settingsmall">RenderStreamingMarkdown <span class="helpicon">?<span
|
||||
class="helptext">Attempt to render markdown when streaming. May result in wonky output or severe lag.</span></span></div>
|
||||
<input title="Show Local Endpoint Selector" type="checkbox" id="render_streaming_markdown" style="margin:0px 0px 0px 0px;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settingitem wide">
|
||||
|
|
83
koboldcpp.py
83
koboldcpp.py
|
@ -4943,6 +4943,10 @@ def show_gui():
|
|||
ctk.CTkButton(extra_tab , text = "Generate LaunchTemplate", command = kcpp_export_template ).grid(row=4,column=0, stick="w", padx= 170, pady=2)
|
||||
makelabel(extra_tab, "Analyze GGUF Metadata", 6, 0,tooltiptxt="Reads the metadata, weight types and tensor names in any GGUF file.")
|
||||
ctk.CTkButton(extra_tab , text = "Analyze GGUF", command = analyze_gguf_model_wrapper ).grid(row=6,column=0, stick="w", padx= 170, pady=2)
|
||||
if os.name == 'nt':
|
||||
makelabel(extra_tab, "File Extensions Handler", 10, 0,tooltiptxt="Makes KoboldCpp the default handler for .kcpps, .kcppt, .ggml and .gguf files.")
|
||||
ctk.CTkButton(extra_tab , text = "Register", width=90, command = register_koboldcpp ).grid(row=10,column=0, stick="w", padx= 170, pady=2)
|
||||
ctk.CTkButton(extra_tab , text = "Unregister", width=90, command = unregister_koboldcpp ).grid(row=10,column=0, stick="w", padx= 264, pady=2)
|
||||
if sys.platform == "linux":
|
||||
def togglezenity(a,b,c):
|
||||
global zenity_permitted
|
||||
|
@ -5444,24 +5448,24 @@ def show_gui_msgbox(title,message):
|
|||
try:
|
||||
from tkinter import messagebox
|
||||
import tkinter as tk
|
||||
root = tk.Tk()
|
||||
root.attributes("-alpha", 0)
|
||||
root2 = tk.Tk()
|
||||
root2.attributes("-alpha", 0)
|
||||
messagebox.showerror(title=title, message=message)
|
||||
root.withdraw()
|
||||
root.quit()
|
||||
root2.withdraw()
|
||||
root2.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def show_gui_yesnobox(title,message):
|
||||
def show_gui_yesnobox(title,message,icon='error'):
|
||||
print(title + ": " + message, flush=True)
|
||||
try:
|
||||
from tkinter import messagebox
|
||||
import tkinter as tk
|
||||
root = tk.Tk()
|
||||
root.attributes("-alpha", 0)
|
||||
result = messagebox.askquestion(title=title, message=message,icon='error')
|
||||
root.withdraw()
|
||||
root.quit()
|
||||
root2 = tk.Tk()
|
||||
root2.attributes("-alpha", 0)
|
||||
result = messagebox.askquestion(title=title, message=message,icon=icon)
|
||||
root2.withdraw()
|
||||
root2.destroy()
|
||||
return result
|
||||
except Exception:
|
||||
return False
|
||||
|
@ -6001,6 +6005,65 @@ def analyze_gguf_model_wrapper(filename=""):
|
|||
dumpthread = threading.Thread(target=analyze_gguf_model, args=(args,filename))
|
||||
dumpthread.start()
|
||||
|
||||
|
||||
def register_koboldcpp():
|
||||
try:
|
||||
exe_path = ""
|
||||
if getattr(sys, 'frozen', False):
|
||||
exe_path = sys.executable
|
||||
if os.name == 'nt' and exe_path!="":
|
||||
confirmyes = show_gui_yesnobox("Confirm Add File Extensions","Do you want to register KoboldCpp as the default file associations for .gguf, .kcpps, .kcppt and .ggml files?",icon="question")
|
||||
if confirmyes == 'yes':
|
||||
import winreg
|
||||
print(f"Registering file associations to {exe_path}")
|
||||
entries = [
|
||||
(r"Software\Classes\KoboldCpp\DefaultIcon", "", f"{exe_path},0"),
|
||||
(r"Software\Classes\KoboldCpp\shell\Open\command", "", f'"{exe_path}" "%1" --singleinstance'),
|
||||
(r"Software\Classes\KoboldCpp\shell\Edit\command", "", f'"{exe_path}" "%1" --singleinstance --showgui'),
|
||||
(r"Software\Classes\.gguf", "", "KoboldCpp"),
|
||||
(r"Software\Classes\.kcpps", "", "KoboldCpp"),
|
||||
(r"Software\Classes\.kcppt", "", "KoboldCpp"),
|
||||
(r"Software\Classes\.ggml", "", "KoboldCpp"),
|
||||
]
|
||||
for key_path, value_name, value_data in entries:
|
||||
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_path) as key:
|
||||
winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value_data)
|
||||
print("KoboldCpp file associations registered successfully.")
|
||||
else:
|
||||
show_gui_msgbox("Cannot Set File Association","File Associations only available for Windows standalone executables.")
|
||||
except Exception as e:
|
||||
print(f"Register Extensions: An error occurred: {e}")
|
||||
|
||||
def unregister_koboldcpp():
|
||||
try:
|
||||
if os.name == 'nt':
|
||||
confirmyes = show_gui_yesnobox("Confirm Remove File Extensions","Do you want to unregister KoboldCpp as the default file associations for .gguf, .kcpps, .kcppt and .ggml files?",icon="question")
|
||||
if confirmyes == 'yes':
|
||||
import winreg
|
||||
keys_to_delete = [
|
||||
r"Software\Classes\KoboldCpp\shell\Edit\command",
|
||||
r"Software\Classes\KoboldCpp\shell\Edit",
|
||||
r"Software\Classes\KoboldCpp\shell\Open\command",
|
||||
r"Software\Classes\KoboldCpp\shell\Open",
|
||||
r"Software\Classes\KoboldCpp\shell",
|
||||
r"Software\Classes\KoboldCpp\DefaultIcon",
|
||||
r"Software\Classes\KoboldCpp",
|
||||
r"Software\Classes\.gguf",
|
||||
r"Software\Classes\.kcpps",
|
||||
r"Software\Classes\.kcppt",
|
||||
r"Software\Classes\.ggml",
|
||||
]
|
||||
for key_path in keys_to_delete:
|
||||
try:
|
||||
winreg.DeleteKey(winreg.HKEY_CURRENT_USER, key_path)
|
||||
except Exception:
|
||||
print(f"Failed to delete registry key: {key_path}")
|
||||
print("KoboldCpp file associations unregistered.")
|
||||
else:
|
||||
show_gui_msgbox("Cannot Set File Association","File Associations only available for Windows standalone executables.")
|
||||
except Exception as e:
|
||||
print(f"Unregister Extensions: An error occurred: {e}")
|
||||
|
||||
def main(launch_args, default_args):
|
||||
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher, sslvalid, global_memory
|
||||
args = launch_args #note: these are NOT shared with the child processes!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue