update comfy generate to use saved workflows

This commit is contained in:
LenAnderson 2023-11-20 12:51:36 +00:00
parent 777d105602
commit d24c74e34a
1 changed files with 12 additions and 1 deletions

View File

@ -2060,7 +2060,18 @@ async function generateComfyImage(prompt) {
'height',
];
let workflow = extension_settings.sd.comfy_workflow.replace('"%prompt%"', JSON.stringify(prompt));
const workflowResponse = await fetch('/api/sd/comfy/workflow', {
method: 'POST',
headers: getRequestHeaders(),
body: JSON.stringify({
file_name: extension_settings.sd.comfy_workflow,
}),
});
if (!workflowResponse.ok) {
const text = await workflowResponse.text();
toastr.error(`Failed to load workflow.\n\n${text}`);
}
let workflow = (await workflowResponse.json()).replace('"%prompt%"', JSON.stringify(prompt));
workflow = workflow.replace('"%seed%"', JSON.stringify(Math.round(Math.random() * Number.MAX_SAFE_INTEGER)));
placeholders.forEach(ph => {
workflow = workflow.replace(`"%${ph}%"`, JSON.stringify(extension_settings.sd[ph]));