rvion / CushyStudio

🛋 The AI and Generative Art platform for everyone
https://docs.cushystudio.com/
GNU Affero General Public License v3.0
684 stars 48 forks source link

Feature Request: Multiple independent prompts #87

Closed ricklove closed 11 months ago

ricklove commented 11 months ago

All the examples have a single await flow.PROMPT() at the end of run (or in a loop with a single value change):

        //        👇 for every value
        for (const i of [1, 2, 3]) {
            //                 👇 we patch the postive text
            positive.json.inputs.text = `a house ${i}`
            //        👇 and re-run the prompt
            await flow.PROMPT()
        }

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?

ricklove commented 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();
ricklove commented 11 months ago

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();
rvion commented 11 months ago

yes, the current refactoring I'm going to release soon is largely related to that.

it includes:

const someOtherGraph = cushy.createComfyWofklow() const myWorkflowOne = cushy.createComfyWofklow() ...

rvion commented 11 months ago

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.