Flow
Waldiez flow model.
WaldiezFlow
¶
Bases: WaldiezBase
Flow data class.
Attributes:
Name | Type | Description |
---|---|---|
id | str | The ID of the flow. |
type | (Literal['flow'], optional) | The type of the "node" in a graph: "flow". |
name | str | The name of the flow. |
description | str | The description of the flow. |
tags | List[str] | The tags of the flow. |
requirements | List[str] | The requirements of the flow. |
storage_id | str | The storage ID of the flow (ignored, UI related). |
created_at | str | The date and time when the flow was created. |
updated_at | str | The date and time when the flow was last updated. |
data | WaldiezFlowData | The data of the flow. See |
cache_seed: Optional[int]
property
¶
Check if the flow has caching disabled.
Returns:
Type | Description |
---|---|
bool | True if the flow has caching disabled, False otherwise. |
get_agent_by_id(agent_id: str) -> WaldiezAgent
¶
Get the agent by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_id | str | The ID of the agent. | required |
Returns:
Type | Description |
---|---|
WaldiezAgent | The agent. |
Raises:
Type | Description |
---|---|
ValueError | If the agent with the given ID is not found. |
Source code in waldiez/models/flow/flow.py
get_agent_connections(agent_id: str, all_chats: bool = True) -> List[str]
¶
Get the agent connections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_id | str | The ID of the agent. | required |
all_chats | bool | If True, get the connections from all the chats, otherwise get the connections from the ordered flow (main chat flow). | True |
Returns:
Type | Description |
---|---|
List[str] | The list of agent ids that the agent with the given ID connects to. |
Source code in waldiez/models/flow/flow.py
get_group_chat_members(group_manager_id: str) -> List[WaldiezAgent]
¶
Get the group chat members.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_manager_id | str | The ID of the group manager. | required |
Returns:
Type | Description |
---|---|
List[WaldiezAgent] | The list of group chat |
Source code in waldiez/models/flow/flow.py
get_initial_swarm_agent() -> Optional[WaldiezAgent]
¶
Get the initial swarm agent.
Returns:
Type | Description |
---|---|
Optional[WaldiezAgent] | The initial swarm agent if found, None otherwise. |
Source code in waldiez/models/flow/flow.py
get_swarm_chat_members(initial_agent: WaldiezAgent) -> Tuple[List[WaldiezAgent], Optional[WaldiezAgent]]
¶
Get the swarm chat members.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_agent | WaldiezAgent | The initial agent. | required |
Returns:
Type | Description |
---|---|
Tuple[List[WaldiezAgent], Optional[WaldiezAgent]] | The list of swarm chat members and the user agent if any. |
Source code in waldiez/models/flow/flow.py
is_async: bool
property
¶
Check if the flow is asynchronous.
Returns:
Type | Description |
---|---|
bool | True if the flow is asynchronous, False otherwise. |
is_single_agent_mode: bool
property
¶
Check if the flow is in single agent mode.
Returns:
Type | Description |
---|---|
bool | True if the flow is in single agent mode, False otherwise. |
is_swarm_flow: bool
property
¶
Check if the flow is a swarm flow.
Returns:
Type | Description |
---|---|
bool | True if the flow is a swarm flow, False otherwise. |
ordered_flow: List[Tuple[WaldiezChat, WaldiezAgent, WaldiezAgent]]
property
¶
Get the ordered flow.
validate_flow() -> Self
¶
Flow validation.
- unique node ids
- there are at least two agents - (or a single agent but not a group manager or a swarm agent)
- all the agents connect to at least one other agent
- all the linked agent skills are found in the flow
- all the linked agent models are found in the flow
- all the managers have at least one member in the chat group
- the ordered flow (chats with position >=0) is not empty
- all agents' code execution config functions exist in the flow skills
- if swarm flow, there is at least one swarm agent
- if swarm flow, there is an initial swarm agent
Returns:
Type | Description |
---|---|
WaldiezFlow | The validated flow. |
Raises:
Type | Description |
---|---|
ValueError | If the ordered flow is empty. If the model IDs are not unique. If the skill IDs are not unique. If the agents do not connect to any other node. If the manager's group chat has no members. |
Source code in waldiez/models/flow/flow.py
validate_flow_models() -> List[str]
¶
Validate the flow models.
Returns:
Type | Description |
---|---|
List[str] | The list of model IDs. |
Raises:
Type | Description |
---|---|
ValueError | If the model IDs are not unique. |
Source code in waldiez/models/flow/flow.py
validate_flow_skills() -> List[str]
¶
Validate the flow skills.
Returns:
Type | Description |
---|---|
List[str] | The list of skill IDs. |
Raises:
Type | Description |
---|---|
ValueError | If the skill IDs are not unique. |
Source code in waldiez/models/flow/flow.py
validate_single_agent_mode(member: WaldiezAgent) -> Self
¶
Flow validation for single agent mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member | WaldiezAgent | The only agent in the flow | required |
Returns:
Type | Description |
---|---|
WaldiezFlow | The validated flow. |
Raises:
Type | Description |
---|---|
ValueError |
|
Source code in waldiez/models/flow/flow.py
Waldiez flow data.
WaldiezFlowData
¶
Bases: WaldiezBase
Flow data class.
Attributes:
Name | Type | Description |
---|---|---|
nodes | List[Dict[str, Any]] | The nodes of the flow. We ignore this (UI-related) |
edges | List[Dict[str, Any]] | The edges of the flow. We ignore this (UI-related) |
viewport | Dict[str, Any] | The viewport of the flow. We ignore this (UI-related) |
agents | WaldiezAgents | The agents of the flow: users: List[WaldiezUserProxy] assistants: List[WaldiezAssistant] managers: List[WaldiezGroupManager] rag_users : List[WaldiezRagUser] See |
models | List[WaldiezModel] | The models of the flow. See |
skills | List[WaldiezSkill] | The skills of the flow. See |
chats | List[WaldiezChat] | The chats of the flow. See |
is_async | bool | Whether the flow is asynchronous or not. |
cache_seed | Optional[int] | The seed for the cache. If None, the seed is not set. Default is 41. |
validate_flow_chats() -> Self
¶
Validate the flow chats.
Returns:
Type | Description |
---|---|
WaldiezFlowData | The flow data. |
Raises:
Type | Description |
---|---|
ValueError | If there is a chat with a prerequisite that does not exist. |