Streaming
Stream real -time updates during workflow execution
Emit events from nodes
namespace App\Neuron;
class ProgressEvent implements Event
{
public function __construct(protected string $msg){}
}namespace App\Neuron;
use NeuronAI\Workflow\Node;
use NeuronAI\Workflow\StartEvent;
use NeuronAI\Workflow\StopEvent;
class InitialNode extends Node
{
public function __invoke(StartEvent $event, WorkflowState $state): \Generator|FirstEvent
{
yield new ProgressEvent("Handling StartEvent");
return new FirstEvent("InitialNode complete");
}
}
class NodeOne extends Node
{
public function __invoke(FirstEvent $event, WorkflowState $state): \Generator|SecondEvent
{
yield new ProgressEvent($event->firstMsg);
return new SecondEvent("NodeOne complete");
}
}
class NodeTwo extends Node
{
public function __invoke(SecondEvent$event, WorkflowState $state): \Generator|StopEvent
{
yield new ProgressEvent($event->secondMsg);
yield new ProgressEvent("NodeTwo complete");
$state->set('message', 'Streaming end');
return new StopEvent();
}
}Stream Agent Output
Monitoring & Debugging
Last updated