🔁 Workflow¶
evoagentx.workflow ¶
WorkFlowGenerator ¶
Bases: BaseModule
Automated workflow generation system based on high-level goals.
The WorkFlowGenerator is responsible for creating complete workflow graphs from high-level goals or task descriptions. It breaks down the goal into subtasks, creates the necessary dependency connections between tasks, and assigns or generates appropriate agents for each task.
Attributes:
Name | Type | Description |
---|---|---|
llm |
Optional[BaseLLM]
|
Language model used for generation and planning |
task_planner |
Optional[TaskPlanner]
|
Component responsible for breaking down goals into subtasks |
agent_generator |
Optional[AgentGenerator]
|
Component responsible for agent assignment or creation |
workflow_reviewer |
Optional[WorkFlowReviewer]
|
Component for reviewing and improving workflows |
num_turns |
Optional[PositiveInt]
|
Number of refinement iterations for the workflow |
Source code in evoagentx/core/module.py
WorkFlowGraph ¶
Bases: BaseModule
Represents a complete workflow as a directed graph.
WorkFlowGraph models a workflow as a directed graph where nodes represent tasks and edges represent dependencies and data flow between tasks. It provides methods for constructing, validating, traversing, and executing workflows.
The graph structure supports advanced features like detecting and handling loops, determining execution order, and tracking execution state.
Attributes:
Name | Type | Description |
---|---|---|
goal |
str
|
The high-level objective of this workflow |
nodes |
Optional[List[WorkFlowNode]]
|
List of WorkFlowNode instances representing tasks |
edges |
Optional[List[WorkFlowEdge]]
|
List of WorkFlowEdge instances representing dependencies |
graph |
Optional[Union[MultiDiGraph, WorkFlowGraph]]
|
Internal NetworkX MultiDiGraph or another WorkFlowGraph |
Source code in evoagentx/core/module.py
edge_exists ¶
Check whether an edge exists in the workflow graph. The input edge
can either be a tuple or a WorkFlowEdge instance.
- If a tuple is passed, it should be (source, target). The function will only determin whether there is an edge between the source node and the target node. If attr_filters is passed, they will also be used to match the edge attributes.
- If a WorkFlowEdge is passed, it will use the eq method in WorkFlowEdge to determine
edge (Union[Tuple[str, str], WorkFlowEdge]):
- If a tuple is provided, it should be in the format `(source, target)`.
The method will check whether there is an edge between the source and target nodes.
If `attr_filters` are provided, they will be used to match edge attributes.
- If a WorkFlowEdge instance is provided, the method will use the `__eq__` method in WorkFlowEdge
to determine whether the edge exists.
attr_filters (dict, optional):
Additional attributes to filter edges when `edge` is a tuple.
bool: True if the edge exists and matches the filters (if provided); False otherwise.
Source code in evoagentx/workflow/workflow_graph.py
get_node ¶
return a WorkFlowNode instance based on its name.
Source code in evoagentx/workflow/workflow_graph.py
set_node_status ¶
Update the state of a specific node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
Union[str, WorkFlowNode]
|
The name of a node or the node instance. |
required |
new_state
|
WorkFlowNodeState
|
The new state to set. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the state was updated successfully, False otherwise. |
Source code in evoagentx/workflow/workflow_graph.py
filter_completed_nodes ¶
remove completed nodes from nodes
Source code in evoagentx/workflow/workflow_graph.py
get_candidate_children_nodes ¶
Return the next set of possible tasks to execute. If there are no loops in the graph, consider only the uncompleted children. If there exists loops, also consider the previous completed tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
completed_nodes
|
List[Union[str, WorkFlowNode]]
|
A list of completed nodes. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of node names that are candidates for execution. |
Source code in evoagentx/workflow/workflow_graph.py
are_dependencies_complete ¶
Check if all predecessors for a node are complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node_name
|
str
|
The name of the task/node to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if all predecessors are complete, False otherwise. |
Source code in evoagentx/workflow/workflow_graph.py
display ¶
Display the workflow graph with node and edge attributes. Nodes are colored based on their status.
Source code in evoagentx/workflow/workflow_graph.py
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
|
SequentialWorkFlowGraph ¶
Bases: WorkFlowGraph
A linear workflow graph with a single path from start to end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
goal
|
str
|
The goal of the workflow. |
required |
tasks
|
List[dict]
|
A list of tasks with their descriptions and inputs. Each task should have the following format: { "name": str, "description": str, "inputs": [{"name": str, "type": str, "required": bool, "description": str}, ...], "outputs": [{"name": str, "type": str, "required": bool, "description": str}, ...], "prompt": str, "system_prompt" (optional): str, default is DEFAULT_SYSTEM_PROMPT, "output_parser" (optional): Type[ActionOutput], "parse_mode" (optional): str, default is "str" "parse_func" (optional): Callable, "parse_title" (optional): str } |
required |
Source code in evoagentx/workflow/workflow_graph.py
get_graph_info ¶
Get the information of the workflow graph.
Source code in evoagentx/workflow/workflow_graph.py
save_module ¶
Save the workflow graph to a module file.
Source code in evoagentx/workflow/workflow_graph.py
WorkFlow ¶
Bases: BaseModule
Source code in evoagentx/core/module.py
execute ¶
Synchronous wrapper for async_execute. Creates a new event loop and runs the async method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
dict
|
Dictionary of inputs for workflow execution |
{}
|
**kwargs
|
Any
|
Additional keyword arguments |
{}
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The output of the workflow execution |
Source code in evoagentx/workflow/workflow.py
async_execute
async
¶
Asynchronously execute the workflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
dict
|
Dictionary of inputs for workflow execution |
{}
|
**kwargs
|
Any
|
Additional keyword arguments |
{}
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The output of the workflow execution |
Source code in evoagentx/workflow/workflow.py
execute_task
async
¶
Asynchronously execute a workflow task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
WorkFlowNode
|
The workflow node to execute |
required |
Source code in evoagentx/workflow/workflow.py
ActionGraph ¶
Bases: BaseModule
Source code in evoagentx/core/module.py
get_graph_info ¶
Get the information of the action graph, including all operators from the instance.
Source code in evoagentx/workflow/action_graph.py
load_module
classmethod
¶
Load the ActionGraph from a file.
Source code in evoagentx/workflow/action_graph.py
from_dict
classmethod
¶
from_dict(data: Dict[str, Any], **kwargs) -> ActionGraph
Create an ActionGraph from a dictionary.
Source code in evoagentx/workflow/action_graph.py
save_module ¶
Save the workflow graph to a module file.