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 property
¶
Check if the flow has caching disabled.
Returns:
Type | Description |
---|---|
bool | True if the flow has caching disabled, False otherwise. |
default classmethod
¶
default() -> WaldiezFlow
Get the default flow.
Returns:
Type | Description |
---|---|
WaldiezFlow | The default flow. |
Source code in waldiez/models/flow/flow.py
get_agent_by_id ¶
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 ¶
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 ¶
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 members. |
Source code in waldiez/models/flow/flow.py
get_group_members ¶
get_group_members(group_id: str) -> list[WaldiezAgent]
Get the group members.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_id | str | The ID of the group. | required |
Returns:
Type | Description |
---|---|
list[WaldiezAgent] | The list of group members. |
Source code in waldiez/models/flow/flow.py
get_root_group_manager ¶
Get the root group manager.
Returns:
Type | Description |
---|---|
WaldiezGroupManager | The root group manager. |
Raises:
Type | Description |
---|---|
ValueError | If no group manager is found. |
Source code in waldiez/models/flow/flow.py
is_async property
¶
is_async: bool
Check if the flow is asynchronous.
Returns:
Type | Description |
---|---|
bool | True if the flow is asynchronous, False otherwise. |
is_single_agent_mode property
¶
is_single_agent_mode: bool
Check if the flow is in single agent mode.
Returns:
Type | Description |
---|---|
bool | True if the flow is in single agent mode, False otherwise. |
unique_names cached
property
¶
Get the unique names for the flow.
Returns:
Type | Description |
---|---|
WaldiezUniqueNames | The unique names for the flow. |
validate_flow ¶
validate_flow() -> Self
Flow validation.
- unique node ids
- there are at least two agents - (or a single agent but not a group manager)
- all the agents connect to at least one other agent
- all the linked agent tools 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 tools
- if group chat flow, there is at least one group manager agent
- if group chat flow, there is an initial group member 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 tool 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
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[WaldiezRagUserProxy] See |
models | list[WaldiezModel] | The models of the flow. See |
tools | list[WaldiezTool] | The tools 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. |
default classmethod
¶
default() -> WaldiezFlowData
Create a default flow data.
Returns:
Type | Description |
---|---|
WaldiezFlowData | The default flow data. |
Source code in waldiez/models/flow/flow_data.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
validate_flow_chats ¶
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. |
Source code in waldiez/models/flow/flow_data.py
get_flow_data ¶
get_flow_data(
data: dict[str, Any],
flow_id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
tags: Optional[list[str]] = None,
requirements: Optional[list[str]] = None,
) -> dict[str, Any]
Get the flow from the passed data dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict[str, Any] | The data dict. | required |
flow_id | Optional[str] | The flow ID, by default None. | None |
name | Optional[str] | The flow name, by default None. | None |
description | Optional[str] | The flow description, by default None. | None |
tags | Optional[list[str]] | The flow tags, by default None. | None |
requirements | Optional[list[str]] | The flow requirements, by default None. | None |
Returns:
Type | Description |
---|---|
dict[str, Any] | The flow data. |
Raises:
Type | Description |
---|---|
ValueError | If the flow type is not "flow". |