|
|
|
@@ -4355,6 +4355,7 @@ Current version indicated by LITEVER below.
|
|
|
|
|
saved_oai_role: 3, //0=user,1=assistant,2=system, 3=auto
|
|
|
|
|
saved_a1111_url: default_a1111_base,
|
|
|
|
|
saved_comfy_url: default_comfy_base,
|
|
|
|
|
saved_comfy_bearer_token: "",
|
|
|
|
|
saved_xtts_url: default_xtts_base,
|
|
|
|
|
saved_alltalk_url: default_alltalk_base,
|
|
|
|
|
saved_mcp_urls: "",
|
|
|
|
@@ -8670,8 +8671,23 @@ Current version indicated by LITEVER below.
|
|
|
|
|
{
|
|
|
|
|
console.log("Attempt ComfyUI Connection...");
|
|
|
|
|
//establish initial connection to a1111 api
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_models_endpoint)
|
|
|
|
|
.then(x => x.json())
|
|
|
|
|
let headers = {};
|
|
|
|
|
if (localsettings.saved_comfy_bearer_token != "") {
|
|
|
|
|
headers['Authorization'] = 'Bearer '+localsettings.saved_comfy_bearer_token
|
|
|
|
|
}
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_models_endpoint, {
|
|
|
|
|
headers: headers
|
|
|
|
|
})
|
|
|
|
|
.then(x => {
|
|
|
|
|
if (!silent && !x.ok) {
|
|
|
|
|
msg = "Connection returned "+x.status
|
|
|
|
|
if (x.status == 401) {
|
|
|
|
|
msg +=". Check Bearer Token."
|
|
|
|
|
}
|
|
|
|
|
msgbox(msg)
|
|
|
|
|
}
|
|
|
|
|
return x.json()
|
|
|
|
|
})
|
|
|
|
|
.then(modelsdata => {
|
|
|
|
|
|
|
|
|
|
if (modelsdata == null || modelsdata.length == 0) {
|
|
|
|
@@ -8690,12 +8706,12 @@ Current version indicated by LITEVER below.
|
|
|
|
|
}).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");
|
|
|
|
|
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. If using ComfyUI-Login, the Bearer Token must match.\n");
|
|
|
|
|
}
|
|
|
|
|
comfyui_is_connected = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_loras_endpoint)
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_loras_endpoint, {headers:headers})
|
|
|
|
|
.then(x => x.json())
|
|
|
|
|
.then(lorasdata => {
|
|
|
|
|
//repopulate our lora list
|
|
|
|
@@ -8735,9 +8751,14 @@ Current version indicated by LITEVER below.
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('image', blob, filename);
|
|
|
|
|
formData.append('overwrite',1);
|
|
|
|
|
let headers = {};
|
|
|
|
|
if (localsettings.saved_comfy_bearer_token != "") {
|
|
|
|
|
headers['Authorization'] = 'Bearer '+localsettings.saved_comfy_bearer_token
|
|
|
|
|
}
|
|
|
|
|
return fetch(`${upload_endpoint}`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData,
|
|
|
|
|
headers: headers,
|
|
|
|
|
}).then(response => {
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error(`Upload failed with status ${response.status}`);
|
|
|
|
@@ -8874,11 +8895,13 @@ Current version indicated by LITEVER below.
|
|
|
|
|
image_db[imgid].type = 0; //0=image, 1=audio
|
|
|
|
|
|
|
|
|
|
uploadBase64ImgToComfy(req_payload["source_image"],comfyimg2imgname).then(() => {
|
|
|
|
|
headers = {'Content-Type': 'application/json'}
|
|
|
|
|
if (localsettings.saved_comfy_bearer_token != "") {
|
|
|
|
|
headers['Authorization'] = 'Bearer '+localsettings.saved_comfy_bearer_token
|
|
|
|
|
}
|
|
|
|
|
fetch(gen_endpoint, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
headers: headers,
|
|
|
|
|
body: JSON.stringify(genimg_payload),
|
|
|
|
|
})
|
|
|
|
|
.then(x => x.json())
|
|
|
|
@@ -9033,6 +9056,15 @@ Current version indicated by LITEVER below.
|
|
|
|
|
},false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function set_comfy_key()
|
|
|
|
|
{
|
|
|
|
|
inputBox("Enter ComfyUI API Auth Bearer Token","ComfyUI API Key",localsettings.saved_comfy_bearer_token,"Input ComfyUI API Key", ()=>{
|
|
|
|
|
let userinput = getInputBoxValue();
|
|
|
|
|
userinput = userinput.trim();
|
|
|
|
|
localsettings.saved_comfy_bearer_token = userinput.trim();
|
|
|
|
|
},true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function generate_pollinations_image(req_payload, autoappend)
|
|
|
|
|
{
|
|
|
|
|
let splits = req_payload.prompt.split("###");
|
|
|
|
@@ -9835,6 +9867,7 @@ Current version indicated by LITEVER below.
|
|
|
|
|
new_save_storyobj.savedsettings.saved_kai_key = "";
|
|
|
|
|
new_save_storyobj.savedsettings.saved_a1111_url = "";
|
|
|
|
|
new_save_storyobj.savedsettings.saved_comfy_url = "";
|
|
|
|
|
new_save_storyobj.savedsettings.saved_comfy_bearer_token = "";
|
|
|
|
|
new_save_storyobj.savedsettings.saved_xtts_url = "";
|
|
|
|
|
new_save_storyobj.savedsettings.saved_mcp_urls = "";
|
|
|
|
|
|
|
|
|
@@ -9976,6 +10009,22 @@ Current version indicated by LITEVER below.
|
|
|
|
|
console.log("Unzip failed: " + error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//try JSONL
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const lines = text.split('\n');
|
|
|
|
|
let temparrs = lines.filter(line => line.trim()).map(line => JSON.parse(line));
|
|
|
|
|
if(temparrs && temparrs.length>1 && temparrs[temparrs.length-1].mes && temparrs[temparrs.length-1].name)
|
|
|
|
|
{
|
|
|
|
|
load_tavern_jsonl(temparrs);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(error)
|
|
|
|
|
{
|
|
|
|
|
console.log("JSONL import failed: " + error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. Fallback to plaintext if .txt
|
|
|
|
|
if (selectedFilename.endsWith(".txt")) {
|
|
|
|
|
msgboxYesNo(
|
|
|
|
@@ -10270,6 +10319,7 @@ Current version indicated by LITEVER below.
|
|
|
|
|
let tmp_kai2 = localsettings.saved_kai_key;
|
|
|
|
|
let tmp_a1111 = localsettings.saved_a1111_url;
|
|
|
|
|
let tmp_comfy = localsettings.saved_comfy_url;
|
|
|
|
|
let tmp_comfy_bearer_token = localsettings.saved_comfy_bearer_token;
|
|
|
|
|
let tmp_xtts = localsettings.saved_xtts_url;
|
|
|
|
|
let tmp_imggen = localsettings.generate_images_mode;
|
|
|
|
|
let tmp_mcp = localsettings.saved_mcp_urls;
|
|
|
|
@@ -10327,6 +10377,7 @@ Current version indicated by LITEVER below.
|
|
|
|
|
localsettings.saved_kai_key = tmp_kai2;
|
|
|
|
|
localsettings.saved_a1111_url = tmp_a1111;
|
|
|
|
|
localsettings.saved_comfy_url = tmp_comfy;
|
|
|
|
|
localsettings.saved_comfy_bearer_token = tmp_comfy_bearer_token;
|
|
|
|
|
localsettings.saved_xtts_url = tmp_xtts;
|
|
|
|
|
localsettings.generate_images_mode = tmp_imggen;
|
|
|
|
|
localsettings.saved_mcp_urls = tmp_mcp;
|
|
|
|
@@ -10614,6 +10665,68 @@ Current version indicated by LITEVER below.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function load_tavern_jsonl(obj)
|
|
|
|
|
{
|
|
|
|
|
if(localsettings.opmode!=3 && localsettings.opmode!=4)
|
|
|
|
|
{
|
|
|
|
|
//force into instruct
|
|
|
|
|
localsettings.opmode = 4;
|
|
|
|
|
}
|
|
|
|
|
gametext_arr = [];
|
|
|
|
|
if(localsettings.opmode==3) //import as chat
|
|
|
|
|
{
|
|
|
|
|
if(localsettings.gui_type_chat!=3)
|
|
|
|
|
{
|
|
|
|
|
localsettings.gui_type_chat = 2;
|
|
|
|
|
}
|
|
|
|
|
for(let i=0;i<obj.length;++i)
|
|
|
|
|
{
|
|
|
|
|
let curr = obj[i];
|
|
|
|
|
if(curr.mes)
|
|
|
|
|
{
|
|
|
|
|
if(curr.name)
|
|
|
|
|
{
|
|
|
|
|
if(curr.is_user)
|
|
|
|
|
{
|
|
|
|
|
localsettings.chatname = curr.name;
|
|
|
|
|
}else{
|
|
|
|
|
localsettings.chatopponent = curr.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gametext_arr.push("\n"+curr.name+": "+curr.mes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else //import as instruct
|
|
|
|
|
{
|
|
|
|
|
localsettings.gui_type_instruct = 2;
|
|
|
|
|
localsettings.inject_chatnames_instruct = true;
|
|
|
|
|
for(let i=0;i<obj.length;++i)
|
|
|
|
|
{
|
|
|
|
|
let curr = obj[i];
|
|
|
|
|
if(curr.mes)
|
|
|
|
|
{
|
|
|
|
|
if(curr.is_user)
|
|
|
|
|
{
|
|
|
|
|
if(curr.name)
|
|
|
|
|
{
|
|
|
|
|
localsettings.chatname = curr.name;
|
|
|
|
|
}
|
|
|
|
|
gametext_arr.push(get_instructstartplaceholder()+curr.name+": "+curr.mes);
|
|
|
|
|
}else{
|
|
|
|
|
if(curr.name)
|
|
|
|
|
{
|
|
|
|
|
localsettings.chatopponent = curr.name;
|
|
|
|
|
}
|
|
|
|
|
gametext_arr.push(get_instructendplaceholder()+curr.name+": "+curr.mes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
update_for_sidepanel();
|
|
|
|
|
render_gametext(true);
|
|
|
|
|
sync_multiplayer(true);
|
|
|
|
|
}
|
|
|
|
|
function load_tavern_obj(obj)
|
|
|
|
|
{
|
|
|
|
|
let selectedgreeting = "";
|
|
|
|
@@ -22656,11 +22769,15 @@ Current version indicated by LITEVER below.
|
|
|
|
|
if(comfyid && comfyid!="")
|
|
|
|
|
{
|
|
|
|
|
//comfyui polling
|
|
|
|
|
let json_headers = {'Content-Type': 'application/json'};
|
|
|
|
|
let headers={};
|
|
|
|
|
if (localsettings.saved_comfy_bearer_token != "") {
|
|
|
|
|
headers['Authorization'] = 'Bearer '+localsettings.saved_comfy_bearer_token;
|
|
|
|
|
json_headers['Authorization'] = 'Bearer '+localsettings.saved_comfy_bearer_token;
|
|
|
|
|
}
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_history_endpoint + "/" + comfyid, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
}
|
|
|
|
|
headers: json_headers,
|
|
|
|
|
})
|
|
|
|
|
.then(x => x.json())
|
|
|
|
|
.then(resp2 => {
|
|
|
|
@@ -22670,7 +22787,7 @@ Current version indicated by LITEVER below.
|
|
|
|
|
img.done = true;
|
|
|
|
|
let finalfilename = resp2[comfyid].outputs["9"].images[0].filename;
|
|
|
|
|
//fetch final image
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_results_endpoint + finalfilename)
|
|
|
|
|
fetch(localsettings.saved_comfy_url + comfy_results_endpoint + finalfilename, {headers: headers})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
return response.blob(); // Convert the response into a Blob
|
|
|
|
|
})
|
|
|
|
@@ -29616,10 +29733,11 @@ Current version indicated by LITEVER below.
|
|
|
|
|
<div id="generate_images_comfy_container" class="settinglabel hidden settingsbox">
|
|
|
|
|
<div class="settinglabel" style="display: flex; width: 100%">
|
|
|
|
|
<div class="justifyleft">Model</div>
|
|
|
|
|
<select title="Select Image Model" class="form-control push-right" id="generate_images_comfy_model" style="width:calc(100% - 58px)">
|
|
|
|
|
<select title="Select Image Model" class="form-control push-right" id="generate_images_comfy_model" style="width:calc(100% - 170px)">
|
|
|
|
|
<option value="">[None]</option>
|
|
|
|
|
</select>
|
|
|
|
|
<button type="button" class="btn btn-primary" onclick="set_comfy_endpoint()" style="width:52px; padding: 2px 2px; margin-left: 3px; font-size:12px;">Set URL</button>
|
|
|
|
|
<button type="button" class="btn btn-primary" onclick="set_comfy_key()" style="width:52px; padding: 2px 2px; margin-left: 3px; font-size:12px;">Set Key</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="settinglabel" style="display: flex; width: 100%">
|
|
|
|
|
<div class="justifyleft">LoRA</div>
|
|
|
|
|