hide flash attention in quick launch for vulkan, updated lite

This commit is contained in:
Concedo 2024-10-24 22:00:09 +08:00
parent becd737e0f
commit d0a6a52855
2 changed files with 323 additions and 44 deletions

View file

@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
-->
<script>
const LITEVER = 180;
const LITEVER = 182;
const urlParams = new URLSearchParams(window.location.search);
var localflag = true;
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
@ -2583,6 +2583,21 @@ Current version indicated by LITEVER below.
"authorsnote": "",
"worldinfo": []
},
{
"title":"Interactive StoryWriter",
"author":"Concedo",
"desc":"This is a different way to co-write a story with the AI. Each turn, the user describes what they want to see happen, and the AI continues the story including that information.",
"opmode":4,
"instruct_starttag": "\\n### Instruction:\\n",
"instruct_endtag": "\\n### Response:\\n",
"hide_user_inputs": true,
"prefmodel1":instructmodels1,
"prefmodel2":instructmodels2,
"prompt":instructendplaceholder+"Please input a story prompt. What is this story about?\n---",
"memory": instructstartplaceholder+"This is a powerful fiction writing tool. Write or continue the same story by adding complete paragraphs of text, trying your best to follow the instruction prompt given. Use slow, descriptive prose, like writing a long novel. Avoid any meta commentary, summaries or analysis, simply continue the same story as if writing a lengthy novel.\n",
"authorsnote": "",
"worldinfo": []
},
{
"title":"Fantasy Isekai",
"author":"Concedo",
@ -3270,13 +3285,21 @@ Current version indicated by LITEVER below.
console.log('.png file ended prematurely: no IEND header was found');
}
//find the chunk with the chara name, just check first and last letter
//find the chunk with the 'chara' name, just check first and last letter
let found = chunks.filter(x => (
x.name == "tEXt"
&& x.data.length > 6
&& String.fromCharCode(x.data[0]) == 'c')
&& String.fromCharCode(x.data[4]) == 'a');
//remove ext asset
found = found.filter(x => (
x.data.length > 12
&& !(String.fromCharCode(x.data[6]) == 'e'
&& String.fromCharCode(x.data[7]) == 'x'
&& String.fromCharCode(x.data[8]) == 't'
&& String.fromCharCode(x.data[9]) == '-')));
if (found.length==0)
{
console.log('PNG Image contains no story data');
@ -4221,6 +4244,11 @@ Current version indicated by LITEVER below.
const a1111_img2img_endpoint = "/sdapi/v1/img2img";
const a1111_interrogate_endpoint = "/sdapi/v1/interrogate";
const comfy_models_endpoint = "/models/checkpoints";
const comfy_generate_endpoint = "/prompt";
const comfy_history_endpoint = "/history";
const comfy_results_endpoint = "/view?filename=";
const xtts_gen_endpoint = "/tts_to_audio/";
const xtts_voices_endpoint = "/speakers_list";
const alltalk_gen_endpoint = "/api/tts-generate";
@ -4239,6 +4267,7 @@ Current version indicated by LITEVER below.
const default_a1111_base = "http://localhost:7860";
const default_xtts_base = " http://localhost:8020";
const default_alltalk_base = "http://localhost:7851";
const default_comfy_base = "http://localhost:8188";
const XTTS_ID = 1000;
const ALLTALK_ID = 1001;
@ -4362,10 +4391,11 @@ Current version indicated by LITEVER below.
saved_oai_custommodel: "", //customized oai custom model
saved_oai_role: 0, //0=user,1=assistant,2=system
saved_a1111_url: default_a1111_base,
saved_comfy_url: default_comfy_base,
saved_xtts_url: default_xtts_base,
saved_alltalk_url: default_alltalk_base,
prev_custom_endpoint_type: 0, //show a reconnect box to custom endpoint if needed. 0 is horde, otherwise its dropdown value+1
generate_images_mode: (localflag?0:1), //0=off, 1=horde, 2=a1111, 3=dalle
generate_images_mode: (localflag?0:1), //0=off, 1=horde, 2=a1111, 3=dalle, 4=comfy
autoscroll: true, //automatically scroll to bottom on render
printer_view: false, //automatically scroll to bottom on render
@ -4403,6 +4433,7 @@ Current version indicated by LITEVER below.
grammar:"",
tokenstreammode: (localflag?2:0), //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_allownsfw: true,
img_cfgscale: 7,
@ -4438,7 +4469,7 @@ Current version indicated by LITEVER below.
darkmode: true,
max_context_length: (localflag?4096:1800),
max_length: 200,
max_length: (localflag?220:200),
auto_ctxlen: true,
auto_genamt: true,
rep_pen: 1.07,
@ -5121,7 +5152,10 @@ Current version indicated by LITEVER below.
{
connect_to_a1111(true);
}
else if(localsettings.generate_images_mode==4)
{
connect_to_comfyui(true);
}
if(!initial_fetched_kudos && localsettings.my_api_key!=defaultsettings.my_api_key)
{
document.getElementById("apikey").value = localsettings.my_api_key;
@ -5237,7 +5271,7 @@ Current version indicated by LITEVER below.
.then(optionsdata => {
console.log(optionsdata);
if (optionsdata.samples_format == null || modelsdata.length == 0) {
msgbox("Invalid data received or no models found. Is A1111 running at the url " + localsettings.saved_a1111_url + " ?");
msgbox("Invalid data received or no models found. Is KoboldCpp / Forge / A1111 running at the url " + localsettings.saved_a1111_url + " ?");
} else {
let a1111_current_loaded_model = optionsdata.sd_model_checkpoint;
console.log("Current model loaded: " + a1111_current_loaded_model);
@ -5254,19 +5288,150 @@ Current version indicated by LITEVER below.
}).catch((error) => {
if(!silent)
{
msgbox("A1111 Connect Error: " + error+"\nPlease make sure A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
msgbox("A1111 Connect Error: " + error+"\nPlease make sure KoboldCpp / Forge / A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
}
a1111_is_connected = false;
});
}).catch((error) => {
if(!silent)
{
msgbox("A1111 Connect Error: " + error+"\nPlease make sure A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
msgbox("A1111 Connect Error: " + error+"\nPlease make sure KoboldCpp / Forge / A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
}
a1111_is_connected = false;
});
}
var comfyui_is_connected = false;
function connect_to_comfyui(silent=false)
{
console.log("Attempt ComfyUI Connection...");
//establish initial connection to a1111 api
fetch(localsettings.saved_comfy_url + comfy_models_endpoint)
.then(x => x.json())
.then(modelsdata => {
if (modelsdata == null || modelsdata.length == 0) {
msgbox("Invalid data received or no models found. Is ComfyUI running at the url " + localsettings.saved_comfy_url + " ?\n\nIt must be launched with the flags --listen --enable-cors-header '*' to enable API access");
} else {
let current_loaded_model = modelsdata[0];
//repopulate our model list
let dropdown = document.getElementById("generate_images_comfy_model");
let selectionhtml = ``;
for (var i = 0; i < modelsdata.length; ++i) {
selectionhtml += `<option value="` + modelsdata[i] + `" `+(current_loaded_model==modelsdata[i]?"selected":"")+`>`+modelsdata[i]+`</option>`;
}
dropdown.innerHTML = selectionhtml;
comfyui_is_connected = true;
}
}).catch((error) => {
if(!silent)
{
msgbox("ComfyUI Connect Error: " + error+"\nPlease make sure ComfyUI is running at "+localsettings.saved_comfy_url+" and properly configured!\n\nIt must be launched with the flags --listen --enable-cors-header '*' to enable API access\n");
}
comfyui_is_connected = false;
});
}
function generate_comfy_image(req_payload)
{
let splits = req_payload.prompt.split("###");
let prompt = splits[0].trim();
let negprompt = (splits.length > 1 ? splits[1] : "");
let genimg_payload = {
"prompt": {
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": req_payload.params.cfg_scale,
"denoise": 1,
"latent_image": ["5", 0],
"model": ["4", 0],
"negative": ["7", 0],
"positive": ["6", 0],
"sampler_name": "euler",
"scheduler": "normal",
"seed": Math.floor(Math.random() * 99999999),
"steps": req_payload.params.steps
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": req_payload.models[0]
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": req_payload.params.height,
"width": req_payload.params.width
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["4", 1],
"text": prompt
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["4", 1],
"text": negprompt
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": ["3", 0],
"vae": ["4", 2]
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "kliteimg",
"images": ["8", 0]
}
}
}
};
let gen_endpoint = localsettings.saved_comfy_url + comfy_generate_endpoint;
console.log(genimg_payload);
fetch(gen_endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(genimg_payload),
})
.then(x => x.json())
.then(resp => {
console.log(resp);
if(resp.prompt_id)
{
let imgid = resp.prompt_id.toString();
let nimgtag = "[<|p|" + imgid + "|p|>]";
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:(req_payload.params.width<req_payload.params.height?1:0));
image_db[imgid].imsource = 0; //0=generated,1=uploaded
}else{
console.log("Generation Error!");
msgbox("Image Generation Failed!\n\nPlease make sure ComfyUI is running and properly configured!\n\nIt must be launched with the flag --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 and properly configured!\n\nIt must be launched with the flag --enable-cors-header '*' to enable API access\n");
});
}
function generate_a1111_image(req_payload, onImagesDone)
{
//split the prompt
@ -5356,7 +5521,7 @@ Current version indicated by LITEVER below.
function set_a1111_endpoint()
{
inputBox("Enter Automatic1111 API endpoint","A1111 Endpoint Selection",localsettings.saved_a1111_url,"Input A1111 API URL", ()=>{
inputBox("Enter Local KoboldCpp / Forge / Automatic1111 API endpoint","KoboldCpp / Forge / A1111 Endpoint Selection",localsettings.saved_a1111_url,"Input A1111 API URL", ()=>{
let userinput = getInputBoxValue();
userinput = userinput.trim();
if(userinput!="" && userinput.slice(-1)=="/")
@ -5374,6 +5539,26 @@ Current version indicated by LITEVER below.
},false);
}
function set_comfy_endpoint()
{
inputBox("Enter ComfyUI API endpoint","ComfyUI Endpoint Selection",localsettings.saved_comfy_url,"Input ComfyUI API URL", ()=>{
let userinput = getInputBoxValue();
userinput = userinput.trim();
if(userinput!="" && userinput.slice(-1)=="/")
{
userinput = userinput.slice(0, -1);
}
if(userinput=="")
{
userinput = default_comfy_base;
}
if (userinput != null && userinput!="") {
localsettings.saved_comfy_url = userinput.trim();
connect_to_comfyui(false);
}
},false);
}
function set_horde_key()
{
inputBox("Enter AI Horde API Key.\n\nThe same key is used for image and text generation in AI Horde.","AI Horde API Key",localsettings.my_api_key,"Input AI Horde API Key", ()=>{
@ -6477,6 +6662,7 @@ Current version indicated by LITEVER below.
let tmp_kai = localsettings.saved_kai_addr;
let tmp_kai2 = localsettings.saved_kai_key;
let tmp_a1111 = localsettings.saved_a1111_url;
let tmp_comfy = localsettings.saved_comfy_url;
let tmp_xtts = localsettings.saved_xtts_url;
let tmp_imggen = localsettings.generate_images_mode;
@ -6516,6 +6702,7 @@ Current version indicated by LITEVER below.
localsettings.saved_kai_addr = tmp_kai;
localsettings.saved_kai_key = tmp_kai2;
localsettings.saved_a1111_url = tmp_a1111;
localsettings.saved_comfy_url = tmp_comfy;
localsettings.saved_xtts_url = tmp_xtts;
localsettings.generate_images_mode = tmp_imggen;
@ -6859,6 +7046,7 @@ Current version indicated by LITEVER below.
"desc":data.description?data.description:"",
"opmode":2,
"adventure_context_mod":false,
"adventure_is_action":true,
"prefmodel1":adventuremodels1,
"prefmodel2":adventuremodels2,
"prompt":data.promptContent?data.promptContent:"",
@ -7436,6 +7624,10 @@ Current version indicated by LITEVER below.
localsettings.opmode = temp_scenario.opmode;
if (temp_scenario.hide_user_inputs===true) {
regexreplace_data.push({"p":`{{\\[INPUT\\]}}\\n.+?\\n{{\\[OUTPUT\\]}}`,"r":"","b":false,"d":true});
}
if(temp_scenario.opmode == 2)
{
@ -8372,7 +8564,7 @@ Current version indicated by LITEVER below.
function togglepalmmodel()
{
let mdlname = document.getElementById("custom_palm_model").value;
if(mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801" || mdlname=="gemini-1.5-pro-exp-0827")
if(mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-pro-001" || mdlname=="gemini-1.5-pro-002" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801" || mdlname=="gemini-1.5-pro-exp-0827")
{
document.getElementById("gemini_system_instruction").classList.remove("hidden");
if(localsettings.saved_palm_jailbreak=="")
@ -8447,11 +8639,15 @@ Current version indicated by LITEVER below.
let desired_oai_ep = document.getElementById("custom_oai_endpoint").value.trim();
desired_oai_ep = transform_oai_ep(desired_oai_ep);
let oaiheaders = {
'Authorization': 'Bearer '+desired_oai_key,
let oaiheaders = {};
if(desired_oai_key!=""){
oaiheaders["Authorization"] = "Bearer " + desired_oai_key;
};
if (!desired_oai_ep.toLowerCase().includes("api.mistral.ai")) {
oaiheaders["x-api-key"] = desired_oai_key;
if(desired_oai_key!="")
{
oaiheaders["x-api-key"] = desired_oai_key;
}
}else{
if(desired_oai_key=="")
{
@ -10049,6 +10245,7 @@ Current version indicated by LITEVER below.
document.getElementById("img_allowhd").checked = localsettings.img_allowhd;
document.getElementById("img_crop").checked = localsettings.img_crop;
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;
document.getElementById("save_remote_images").checked = localsettings.save_remote_images;
document.getElementById("img_cfgscale").value = localsettings.img_cfgscale;
@ -10343,6 +10540,7 @@ Current version indicated by LITEVER below.
localsettings.img_crop = (document.getElementById("img_crop").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);
localsettings.prompt_for_savename = (document.getElementById("prompt_for_savename").checked ? true : false);
@ -10513,15 +10711,12 @@ Current version indicated by LITEVER below.
function toggle_generate_images_mode(silent=false)
{
if(document.getElementById("generate_images_mode").value==0)
{
document.getElementById("generate_images_model_container").classList.add("hidden");
document.getElementById("generate_images_dalle_container").classList.add("hidden");
document.getElementById("generate_images_local_model_container").classList.add("hidden");
}else if(document.getElementById("generate_images_mode").value==1){
document.getElementById("generate_images_model_container").classList.add("hidden");
document.getElementById("generate_images_dalle_container").classList.add("hidden");
document.getElementById("generate_images_local_model_container").classList.add("hidden");
document.getElementById("generate_images_comfy_container").classList.add("hidden");
if(document.getElementById("generate_images_mode").value==1){
document.getElementById("generate_images_model_container").classList.remove("hidden");
document.getElementById("generate_images_dalle_container").classList.add("hidden");
document.getElementById("generate_images_local_model_container").classList.add("hidden");
if(!image_models_fetched)
{
//doing it this way will be more buggy,
@ -10531,14 +10726,13 @@ Current version indicated by LITEVER below.
});
}
}else if(document.getElementById("generate_images_mode").value==2){
document.getElementById("generate_images_model_container").classList.add("hidden");
document.getElementById("generate_images_dalle_container").classList.add("hidden");
document.getElementById("generate_images_local_model_container").classList.remove("hidden");
connect_to_a1111(silent);
}else if(document.getElementById("generate_images_mode").value==3){
document.getElementById("generate_images_model_container").classList.add("hidden");
document.getElementById("generate_images_dalle_container").classList.remove("hidden");
document.getElementById("generate_images_local_model_container").classList.add("hidden");
}else if(document.getElementById("generate_images_mode").value==4){
document.getElementById("generate_images_comfy_container").classList.remove("hidden");
connect_to_comfyui(silent);
}
}
@ -11382,7 +11576,7 @@ Current version indicated by LITEVER below.
let imgid = "selfuploadimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]";
gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:"", local:true };
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
let imgres = localsettings.img_allowhd?HD_RES_PX:NO_HD_RES_PX;
@ -11849,6 +12043,16 @@ Current version indicated by LITEVER below.
{
warn_on_quit = true;
let newgen = document.getElementById("input_text").value;
let img_gen_trigger_prompt = "";
let doNotGenerate = 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\n") &&
newgen.match(/\b(?:draw me (?:a|an)\b)|(?:(?:draw|show me|generate|create|make|illustrate|visualize|produce|give me)(?:\s\w+){0,3}\s(?:image|picture|drawing|photo))/))
{
img_gen_trigger_prompt = newgen;
doNotGenerate = true;
}
//apply regex transforms
if(regexreplace_data && regexreplace_data.length>0)
@ -11864,7 +12068,6 @@ Current version indicated by LITEVER below.
}
const user_input_empty = (newgen.trim()=="");
let doNotGenerate = false;
pending_context_postinjection = "";
if (!user_input_empty || gametext_arr.length > 0 || current_memory != "" || current_anote != "")
@ -12457,6 +12660,14 @@ Current version indicated by LITEVER below.
pending_response_id = "";
}
if(img_gen_trigger_prompt!="")
{
let txt = "I'll try and create that image.";
gametext_arr.push(txt);
var sentence = img_gen_trigger_prompt.trim().substring(0, 380);
do_manual_gen_image(sentence);
}
render_gametext();
}
is_impersonate_user = false;
@ -13042,7 +13253,7 @@ Current version indicated by LITEVER below.
};
let sysinst = document.getElementById("gemini_system_instruction").value;
if(sysinst!="" && (mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801"))
if(sysinst!="" && (mdlname=="gemini-1.5-pro-latest" || mdlname=="gemini-1.5-pro-001" || mdlname=="gemini-1.5-pro-002" || mdlname=="gemini-1.5-flash-latest" || mdlname=="gemini-1.5-pro-exp-0801"))
{
payload["systemInstruction"] = {
"role": "system",
@ -13410,7 +13621,7 @@ Current version indicated by LITEVER below.
//for now, append the new image directly into the gtarr
let nimgtag = "[<|p|" + data.id + "|p|>]";
gametext_arr.push(nimgtag);
image_db[data.id] = { done: false, queue: "Starting", result: "", prompt:sentence, local:false };
image_db[data.id] = { done: false, queue: "Starting", result: "", prompt:sentence, poll_category:1 };
image_db[data.id].aspect = (iwidth>iheight?2:(iwidth<iheight?1:0));
image_db[data.id].imsource = 0; //0=generated,1=uploaded
console.log("New image queued " + nimgtag);
@ -13432,7 +13643,7 @@ Current version indicated by LITEVER below.
let imgid = "A1111img"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]";
gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, local:true };
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, poll_category:0 };
image_db[imgid].aspect = (iwidth>iheight?2:(iwidth<iheight?1:0));
image_db[imgid].imsource = 0; //0=generated,1=uploaded
generate_a1111_image(genimg_payload,(outputimg)=>{
@ -13447,7 +13658,7 @@ Current version indicated by LITEVER below.
}, true, false, imgres,0.35,false);
}else{
image_db[imgid].queue = "Failed";
msgbox("Image Generation Failed!\n\nPlease make sure A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
msgbox("Image Generation Failed!\n\nPlease make sure KoboldCpp / Forge / A1111 is running and properly configured!\nIn your local install of Automatic1111 WebUi, modify webui-user.bat and add these flags to enable API access:\n\nset COMMANDLINE_ARGS= --api --listen --cors-allow-origins=*\n");
}
});
}
@ -13462,7 +13673,7 @@ Current version indicated by LITEVER below.
let imgid = "DALLEimg"+(Math.floor(10000 + Math.random() * 90000)).toString();
let nimgtag = "[<|p|" + imgid + "|p|>]";
gametext_arr.push(nimgtag);
image_db[imgid] = { done: false, queue: "Generating", result: "", prompt:sentence, local:true };
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
generate_dalle_image(genimg_payload,(outputimg)=>{
@ -13482,6 +13693,12 @@ Current version indicated by LITEVER below.
});
}
}
else if(localsettings.generate_images_mode==4) //comfyui
{
let desired_model = document.getElementById("generate_images_comfy_model").value;
genimg_payload.models = [desired_model];
generate_comfy_image(genimg_payload);
}
}
function interrogate_new_image(base64img, imghash, use_horde=true)
@ -13546,7 +13763,7 @@ Current version indicated by LITEVER below.
.then((data) => {
console.log('interrogate img result:', data);
if (data.id && data.id != "") {
interrogation_db[data.id] = { done: false, result: "", imghash:imghash, local:false };
interrogation_db[data.id] = { done: false, result: "", imghash:imghash, poll_category:1 };
console.log("New interrogate queued: " + data.id);
}
else {
@ -13633,12 +13850,12 @@ Current version indicated by LITEVER below.
let togglebtn = `<select class="form-control" id="aivisionmode" style="display:inline;height:24px;width: 140px; padding: 2px; margin: 3px; font-size:12px;" onchange="toggle_ai_vision(\'`+imghash+`\')">
<option value="0">Disabled</option>
<option value="1">Interrogate (Horde)</option>
<option value="2">Interrogate (A1111)</option>
<option value="2">Interrogate (KCPP / Forge / A1111)</option>
<option value="3">Multimodal (LLaVA)</option>
<option value="4">OpenAI Vision (API)</option>
</select>`;
document.getElementById("zoomedimgdesc").innerHTML = `
AI Vision: `+visionstatus+` <span class="helpicon">?<span class="helptext">Allows the AI to see and react to this image. On KoboldCpp, LLaVA models can be used. Horde or Local A1111 use image interrogation if enabled. For OpenAI API, only works with Vision Models like Gpt4o.</span></span>
AI Vision: `+visionstatus+` <span class="helpicon">?<span class="helptext">Allows the AI to see and react to this image. On KoboldCpp, LLaVA models can be used. Horde or Local KoboldCpp / Forge / A1111 use image interrogation if enabled. For OpenAI API, only works with Vision Models like Gpt4o.</span></span>
`+togglebtn+`
<br><button type="button" class="btn btn-primary" style="width: 140px; padding: 2px; margin: 3px; font-size:12px;" onclick="show_orig_prompt()">View Original Prompt</button>
<button type="button" class="btn btn-primary" style="width: 110px; padding: 2px; margin: 3px; font-size:12px;" onclick="add_img2img()">Create Img2Img</button>
@ -14055,7 +14272,7 @@ Current version indicated by LITEVER below.
console.log("polling for pending interrogations " + imagecount);
for (let key in interrogation_db) {
let img = interrogation_db[key];
if (img.done == false && !img.local) {
if (img.done == false && img.poll_category==1) {
//call check
fetch(stablehorde_output_interrogate_endpoint + "/" + key)
.then(x => x.json())
@ -14108,7 +14325,7 @@ Current version indicated by LITEVER below.
console.log("polling for pending images " + imagecount);
for (let key in image_db) {
let img = image_db[key];
if (img.done == false && !img.local) {
if (img.done == false && img.poll_category==1) {
//call check
fetch(stablehorde_poll_endpoint + "/" + key)
.then(x => x.json())
@ -14158,6 +14375,52 @@ Current version indicated by LITEVER below.
delete image_db[key];
});
}
else if (img.done == false && img.poll_category==2)
{
//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?HD_RES_PX:NO_HD_RES_PX;
compressImage(origImg, (newDataUri) => {
img.result = newDataUri;
}, true, false, imgres,0.35,false);
};
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 and properly configured!\n\nIt must be launched with the flag --enable-cors-header '*' to enable API access\n");
});
}
}
//now we loop through the image cache and swap completed images into the gametext
@ -17765,7 +18028,7 @@ Current version indicated by LITEVER below.
<li class="nav-item hidden" id="topbtn_save_load">
<a id="tempfile" href="#" style="display:none;"></a>
<input type="file" id="loadfileinput" accept="text/json,application/json,image/png,image/webp,.kaistory,.webp,.png,.json,.txt,*.*,*" onchange="load_file(event)" style="display:none;">
<input type="file" id="loadfileinput" accept="text/json,application/json,image/png,image/webp,text/plain,*/*" onchange="load_file(event)" style="display:none;">
<a class="nav-link mainnav" href="#" onclick="closeTopNav();display_saveloadcontainer()">Save / Load</a>
</li>
<li class="nav-item hidden" id="topbtn_settings">
@ -17850,7 +18113,6 @@ Current version indicated by LITEVER below.
<button type="button" class="btn btn-primary mainnav" id="btn_actretry2" onclick="btn_retry()">Retry</button>
<button type="button" class="btn btn-primary bg_green mainnav" id="btn_genimg2" onclick="add_img_btn_menu()">Add Img</button>
<button type="button" class="btn btn-primary mainnav" id="btn_editmode" onclick="btn_editmode()">Edit</button>
</div>
</div>
@ -18231,6 +18493,8 @@ Current version indicated by LITEVER below.
Note that KoboldAI Lite takes no responsibility for your usage or consequences of this feature. Your API key is used directly with the Gemini API and is not transmitted to us.<br><br>
<select style="padding:4px;" class="form-control" id="custom_palm_model" onchange="togglepalmmodel()">
<option value="gemini-pro" selected="selected">gemini-pro</option>
<option value="gemini-1.5-pro-001">gemini-1.5-pro-001</option>
<option value="gemini-1.5-pro-002">gemini-1.5-pro-002</option>
<option value="gemini-1.5-pro-latest">gemini-1.5-pro-latest</option>
<option value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option>
<option value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option>
@ -18832,13 +19096,14 @@ Current version indicated by LITEVER below.
<div id="settingsmenumedia" class="settingsmenu hidden" onchange="setting_tweaked()">
<div class="settingitem">
<div class="settinglabel">
<div class="justifyleft settingsmall">Generate Images <span class="helpicon">?<span class="helptext">Use the AI Horde or a local A1111 instance to insert AI generated images into your story.</span></span></div>
<div class="justifyleft settingsmall">Generate Images <span class="helpicon">?<span class="helptext">Use the AI Horde or a local KoboldCpp / Forge / A1111 instance to insert AI generated images into your story.</span></span></div>
</div>
<select title="Generate Images" class="form-control" id="generate_images_mode" style="height:20px;padding:0;margin:0px 0 0;" onchange="toggle_generate_images_mode(true)">
<option value="0">[Disabled]</option>
<option value="1">AI Horde</option>
<option value="2">Local A1111</option>
<option value="2">KCPP / Forge / A1111</option>
<option value="3">OpenAI DALL-E</option>
<option value="4">ComfyUI</option>
</select>
<div id="generate_images_model_container" class="hidden">
<select class="form-control" id="generate_images_model" style="font-size: 12px;height:20px;padding:2px;margin:0px 0 0;" onblur="validate_sd_model()" title="Stable Diffusion Model Selection">
@ -18856,10 +19121,16 @@ Current version indicated by LITEVER below.
</select>
<button type="button" class="btn btn-primary" onclick="set_a1111_endpoint()" style="height: 20px; padding: 0px 2px; margin: 0px 0px 0px 3px;">⚙️</button>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Save images remotely on A1111 host (caution)">Save In A1111 </div>
<div class="justifyleft settingsmall" title="Save images remotely on A1111/Forge host (caution)">Save In A1111/Forge </div>
<input type="checkbox" id="save_remote_images" style="margin:0px 0 0;">
</div>
</div>
<div id="generate_images_comfy_container" class="settinglabel hidden">
<select title="Select Image Model" class="form-control" id="generate_images_comfy_model" style="height:20px;padding:0;margin:0px 0 0; width:calc(100% - 30px)">
<option value="">[None]</option>
</select>
<button type="button" class="btn btn-primary" onclick="set_comfy_endpoint()" style="height: 20px; padding: 0px 2px; margin: 0px 0px 0px 3px;">⚙️</button>
</div>
<div id="generate_images_dalle_container" class="settinglabel hidden">
<table width="100%"><tr>
<td><button type="button" class="btn btn-primary" style="width:100%; padding:2px 3px;margin-top:2px;font-size:11px;" onclick="set_dalle_url()">Set URL</button></td>
@ -18871,6 +19142,10 @@ Current version indicated by LITEVER below.
<div id="genimgopt" class="">
<table>
<tr><td>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Parse user input text in instruct mode, and trigger image generation if requested">Detect ImgGen Instructions </div>
<input title="Detect ImgGen Instructions" type="checkbox" id="img_gen_from_instruct" style="margin:0px 0 0;">
</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 0 0;">

View file

@ -2703,9 +2703,12 @@ def show_gui():
tensor_split_entry.grid_remove()
splitmode_box.grid_remove()
if index == "Use Vulkan":
if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)":
tensor_split_label.grid(row=8, column=0, padx = 8, pady=1, stick="nw")
tensor_split_entry.grid(row=8, column=1, padx=8, pady=1, stick="nw")
quick_use_flashattn.grid_remove()
else:
quick_use_flashattn.grid(row=22, column=1, padx=8, pady=1, stick="nw")
if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Old CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)":
gpu_layers_label.grid(row=6, column=0, padx = 8, pady=1, stick="nw")
@ -2755,13 +2758,14 @@ def show_gui():
"Disable MMAP": [disablemmap, "Avoids using mmap to load models if enabled"],
"Use ContextShift": [contextshift, "Uses Context Shifting to reduce reprocessing.\nRecommended. Check the wiki for more info."],
"Remote Tunnel": [remotetunnel, "Creates a trycloudflare tunnel.\nAllows you to access koboldcpp from other devices over an internet URL."],
"Use FlashAttention": [flashattention, "Enable flash attention for GGUF models."],
"Quiet Mode": [quietmode, "Prevents all generation related terminal output from being displayed."]
}
for idx, (name, properties) in enumerate(quick_boxes.items()):
makecheckbox(quick_tab, name, properties[0], int(idx/2) + 20, idx % 2, tooltiptxt=properties[1])
quick_use_flashattn = makecheckbox(quick_tab, "Use FlashAttention", flashattention, 22, 1, tooltiptxt="Enable flash attention for GGUF models.")
# context size
makeslider(quick_tab, "Context Size:", contextsize_text, context_var, 0, len(contextsize_text)-1, 30, width=280, set=5,tooltip="What is the maximum context size to support. Model specific. You cannot exceed it.\nLarger contexts require more memory, and not all models support it.")