diff --git a/embd_res/klite.embd b/embd_res/klite.embd index 28e43d6c4..a59dd04ba 100644 --- a/embd_res/klite.embd +++ b/embd_res/klite.embd @@ -3524,6 +3524,7 @@ Current version indicated by LITEVER below. const a1111_interrogate_endpoint = "/sdapi/v1/interrogate"; const comfy_models_endpoint = "/models/checkpoints"; + const comfy_loras_endpoint = "/models/loras"; const comfy_generate_endpoint = "/prompt"; const comfy_history_endpoint = "/history"; const comfy_results_endpoint = "/view?filename="; @@ -6921,7 +6922,7 @@ Current version indicated by LITEVER below. .replace(/\*\*\*([^\s*][\s\S]*?[^\\])\*\*\*/gm, "$1") .replace(/\*\*(.)\*\*/g, "$1") //handle single char bold - .replace(/ \*\*(\w+(?: \w+)?)\*\* /g, " $1 ") //hack: support 1 or 2 nested bolded words (not official) + .replace(/([ ,.?!:])\*\*(\w+(?: \w+)?)\*\*([ ,.?!:])/g, "$1$2$3") //hack: support 1 or 2 nested bolded words (not official) .replace(/\*\*([^\s*][\s\S]*?[^\\])\*\*/gm, "$1") .replace(/(^|[\s.,;:!?<>])\*(.)\*(?=[\s.,;:!?<>]|$)/g, "$1$2") //handle single char italics .replace(/\*([^\s*][\s\S]*?[^\\])\*/gm, "$1") @@ -7390,6 +7391,31 @@ Current version indicated by LITEVER below. } comfyui_is_connected = false; }); + + fetch(localsettings.saved_comfy_url + comfy_loras_endpoint) + .then(x => x.json()) + .then(lorasdata => { + //repopulate our lora list + let dropdown_lora = document.getElementById("generate_images_comfy_lora"); + let loraSelectionHtml = ``; + if (lorasdata == null || lorasdata.length == 0) { + dropdown_lora.disabled = true; + loraSelectionHtml = ``; + } else { + dropdown_lora.disabled = false; + let current_loaded_model = lorasdata[0]; + loraSelectionHtml += ``; + for (var i = 0; i < lorasdata.length; ++i) { + loraSelectionHtml += ``; + } + } + dropdown_lora.innerHTML = loraSelectionHtml; + }).catch((error) => { + console.log(error); + let dropdown_lora = document.getElementById("generate_images_comfy_lora"); + dropdown_lora.disabled = true; + loraSelectionHtml = ``; + }); } function uploadBase64ImgToComfy(base64Data,filename) { @@ -7419,6 +7445,8 @@ Current version indicated by LITEVER below. function generate_comfy_image(req_payload, autoappend) { + let dropdown_lora = document.getElementById("generate_images_comfy_lora"); + let use_lora = ((dropdown_lora && dropdown_lora.disabled==false && dropdown_lora.value != "") ? true : false); let splits = req_payload.prompt.split("###"); let prompt = splits[0].trim(); let negprompt = (splits.length > 1 ? splits[1] : ""); @@ -7432,7 +7460,7 @@ Current version indicated by LITEVER below. "cfg": req_payload.params.cfg_scale, "denoise": 1, "latent_image": ["5", 0], - "model": ["4", 0], + "model": use_lora ? ["11", 0] : ["4", 0], "negative": ["7", 0], "positive": ["6", 0], "sampler_name": "euler", @@ -7458,15 +7486,15 @@ Current version indicated by LITEVER below. "6": { "class_type": "CLIPTextEncode", "inputs": { - "clip": ["4", 1], - "text": prompt + "text": prompt, + "clip": use_lora ? ["11", 1] : ["4", 1] } }, "7": { "class_type": "CLIPTextEncode", "inputs": { - "clip": ["4", 1], - "text": negprompt + "text": negprompt, + "clip": use_lora ? ["11", 1] : ["4", 1] } }, "8": { @@ -7486,6 +7514,19 @@ Current version indicated by LITEVER below. } }; + if (use_lora) { + genimg_payload.prompt["11"] = { + "class_type": "LoraLoader", + "inputs": { + "lora_name": dropdown_lora.value, + "strength_model": 1.0, + "strength_clip": 1.0, + "model": ["4", 0], + "clip": ["4", 1] + } + }; + } + if(req_payload["source_image"]) //override with img2img nodes { genimg_payload["prompt"]["5"] = { @@ -27060,6 +27101,9 @@ Current version indicated by LITEVER below. +