Skip to content

Index

Waldiez agents model.

WaldiezAgents

Bases: WaldiezBase

Waldiez agents model.

Attributes:

NameTypeDescription
userProxyAgentslist[WaldiezUserProxy]

User proxy agents.

assistantAgentslist[WaldiezAssistant]

Assistant agents.

ragUserProxyAgentslist[WaldiezRagUserProxy]

RAG user proxy agents.

reasoningAgentslist[WaldiezReasoningAgent]

Reasoning agents.

captainAgentslist[WaldiezCaptainAgent]

Captain agents.

groupManagerAgentslist[WaldiezGroupManager]

Group manager agents.

members property

Get all agents.

Yields:

TypeDescription
WaldiezAgent

The agents.

validate_agents

validate_agents() -> Self

Validate the agents.

  • At least two agents are required.
  • All the agent IDs must be unique.

Returns:

TypeDescription
WaldiezAgents

The agents.

Raises:

TypeDescription
ValueError

If the agents are invalid.

Source code in waldiez/models/agents/agents.py
@model_validator(mode="after")
def validate_agents(self) -> Self:
    """Validate the agents.

    - At least two agents are required.
    - All the agent IDs must be unique.

    Returns
    -------
    WaldiezAgents
        The agents.

    Raises
    ------
    ValueError
        If the agents are invalid.
    """
    all_agent_ids = [agent.id for agent in self.members]
    if len(all_agent_ids) < 1:
        raise ValueError("At least one agent is required.")
    if len(all_agent_ids) != len(set(all_agent_ids)):
        raise ValueError("Agent IDs must be unique.")
    return self

validate_flow

validate_flow(
    model_ids: list[str], tool_ids: list[str]
) -> None

Validate the flow of the agents.

  • Validate the linked models (the referenced model ids must exist).
  • Validate the linked tools (the referenced tool ids must exist).
  • Validate the code execution (the referenced functions must exist).

Parameters:

NameTypeDescriptionDefault
model_idslist[str]

The list of model IDs.

required
tool_idslist[str]

The list of tool IDs.

required

Raises:

TypeDescription
ValueError

If the flow is invalid.

Source code in waldiez/models/agents/agents.py
def validate_flow(self, model_ids: list[str], tool_ids: list[str]) -> None:
    """Validate the flow of the agents.

    - Validate the linked models (the referenced model ids must exist).
    - Validate the linked tools (the referenced tool ids must exist).
    - Validate the code execution (the referenced functions must exist).

    Parameters
    ----------
    model_ids : list[str]
        The list of model IDs.
    tool_ids : list[str]
        The list of tool IDs.

    Raises
    ------
    ValueError
        If the flow is invalid.
    """
    all_agent_ids = [agent.id for agent in self.members]
    for agent in self.members:
        agent.validate_linked_models(model_ids)
        agent.validate_linked_tools(tool_ids, agent_ids=all_agent_ids)
        agent.validate_code_execution(tool_ids=tool_ids)
        if agent.is_group_manager and isinstance(
            agent, WaldiezGroupManager
        ):
            agent.validate_initial_agent_id(all_agent_ids)
            agent.validate_transitions(agent_ids=all_agent_ids)