Skip to content

3.4.0

Choose a tag to compare

@ilvalerione ilvalerione released this 02 May 14:10
· 118 commits to 3.x since this release

Introducing Parallel Branches

This release introduce the ability of the workflow component to run parallel branches: https://docs.neuron-ai.dev/workflow/loops-and-branches#parallel-branches

When you want to call the execution of multiple branches in parallel, you need to return the special event ParallelEvent from your node.

use NeuronAI\Workflow\Events\ParallelEvent;

class DocumentProcessing extends Node
{
    public function __invoke(StartEvent $event, WorkflowState $state): ParallelEvent
    {
        // Node logic here...
	
        // Finally return a ParallelEvent
        return new ParallelEvent([
            'text' => new TextProcessEvent(),
            'image' => new ImageProcessEvent(),
        ]);
    }
}