Closed ricklove closed 11 months ago
Ok, it looks like disabling all the nodes of the current workflow works. Disabled nodes are not sent in the next prompt, but they are still around to receive state changes for a running prompt etc.
// ... Build first graph
// Run first graph
const result = await flow.PROMPT();
// Disable all nodes
flow.workflow.nodes.forEach((x) => x.disable());
// Build new graph
const startImage2 = await flow.loadImageAnswer(form.startImage);
graph.PreviewImage({ images: startImage2 });
// Run new graph
await flow.PROMPT();
It also works fine to disable only part of the old graph:
// Run the graph you built
const result = await flow.PROMPT();
// Disable some nodes
const iDisableStart = flow.workflow.nodes.indexOf(cropMask) + 1;
flow.workflow.nodes.slice(iDisableStart).forEach((x) => x.disable());
// Build new graph with part of old graph
graph.PreviewImage({ images: cropMask.outputs.Heatmap$_Mask });
// Run new graph
await flow.PROMPT();
yes, the current refactoring I'm going to release soon is largely related to that.
it includes:
graphs
will be renamed ComfyWorkflows
ComfyWofklow
instanciated by default.flow.run()
by default
const graph = cushy.createComfyWofklow()
graph.PreviewImage({...})
await graph.PROMPT()
const someOtherGraph = cushy.createComfyWofklow() const myWorkflowOne = cushy.createComfyWofklow() ...
It also works fine to disable only part of the old graph:
// Run the graph you built const result = await flow.PROMPT(); // Disable some nodes const iDisableStart = flow.workflow.nodes.indexOf(cropMask) + 1; flow.workflow.nodes.slice(iDisableStart).forEach((x) => x.disable()); // Build new graph with part of old graph graph.PreviewImage({ images: cropMask.outputs.Heatmap$_Mask }); // Run new graph await flow.PROMPT();
but this is also very nice. this method should totally live on the (currently named) GraphL
. Graphs are indeed made to be manipulated, made dynamic, so one app can run the same workflow multiple times, mutating it along execution.
All the examples have a single
await flow.PROMPT()
at the end of run (or in a loop with a single value change):However, I want to create a new graph after awaiting a prompt (instead of looping over and reusing an existing one).
Is there any possible way to do this?