Expand description
DAG-based Workflow System
Provides a directed acyclic graph (DAG) based workflow execution system with support for conditional branching, human-in-the-loop patterns, and complex task orchestration.
§Example
ⓘ
use cortexai_crew::workflow::{Workflow, WorkflowBuilder, NextAction};
let workflow = WorkflowBuilder::new("approval_flow")
.add_node("validate", validate_task)
.add_node("approve", approve_task)
.add_node("execute", execute_task)
.add_node("reject", reject_task)
.connect("validate", "approve", Some(Condition::when("valid", true)))
.connect("validate", "reject", Some(Condition::when("valid", false)))
.connect("approve", "execute", None)
.set_entry("validate")
.build();
let mut runner = WorkflowRunner::new(workflow);
loop {
match runner.step(context).await? {
NextAction::Continue => continue,
NextAction::WaitForInput(prompt) => {
let input = get_user_input(&prompt);
runner.provide_input(input);
}
NextAction::Complete(result) => break result,
}
}Structs§
- Condition
- Condition for edge traversal
- Input
Request - Request for external input
- Node
Execution - Record of a node execution
- Workflow
- Workflow definition
- Workflow
Builder - Builder for creating workflows
- Workflow
Context - Execution context for workflows
- Workflow
Edge - An edge connecting two nodes
- Workflow
Node - A node in the workflow graph
- Workflow
Result - Result of a completed workflow
- Workflow
Runner - Workflow execution runner
Enums§
- Condition
Operator - Comparison operators for conditions
- Input
Type - Type of input expected
- Next
Action - Action to take after a workflow step
- Node
Result - Result of a single node execution
- Node
Type - Type of workflow node
- Workflow
Status - Workflow execution status
Traits§
- Node
Executor - Trait for custom node executors