Agent
Base agent class to be inherited by all agents.
WaldiezAgent
¶
Bases: WaldiezBase
Waldiez Agent.
Attributes:
Name | Type | Description |
---|---|---|
id | str | The ID of the agent. |
type | Literal['agent'] | The type of the "node" in a graph: "agent" |
agent_type | WaldiezAgentType | The type of the agent |
name | str | The name of the agent. |
description | str | The description of the agent. |
tags | List[str] | Tags for this agent. |
requirements | List[str] | Python requirements for the agent. |
created_at | str | The date and time when the agent was created. |
updated_at | str | The date and time when the agent was last updated. |
data | WaldiezAgentData | The data (properties) of this agent. See |
Methods:
Name | Description |
---|---|
validate_linked_skills | Validate the skills linked to the agent. |
validate_linked_models | Validate the models linked to the agent. |
ag2_class: str
property
¶
Return the AG2 class of the agent.
ag2_imports: Set[str]
property
¶
Return the AG2 imports of the agent.
validate_code_execution(skill_ids: List[str]) -> None
¶
Validate the code execution config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
skill_ids | List[str] | The list of skill IDs. | required |
Raises:
Type | Description |
---|---|
ValueError | If a function is not found |
Source code in waldiez/models/agents/agent/agent.py
validate_linked_models(model_ids: List[str]) -> None
¶
Validate the models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_ids | List[str] | The list of model IDs. | required |
Raises:
Type | Description |
---|---|
ValueError | If a model is not found |
Source code in waldiez/models/agents/agent/agent.py
validate_linked_skills(skill_ids: List[str], agent_ids: List[str]) -> None
¶
Validate the skills.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
skill_ids | List[str] | The list of skill IDs. | required |
agent_ids | List[str] | The list of agent IDs. | required |
Raises:
Type | Description |
---|---|
ValueError | If a skill or agent is not found |
Source code in waldiez/models/agents/agent/agent.py
Common data structures for agents.
WaldiezAgentData
¶
Bases: WaldiezBase
Waldiez Agent Data.
Attributes:
Name | Type | Description |
---|---|---|
system_message | Optional[str] | The agent's system message. Default: None (depends on the agent's type) |
human_input_mode | Literal['ALWAYS', 'NEVER', 'TERMINATE'] | The human input mode to use for the agent. |
code_execution_config | Union[WaldiezAgentCodeExecutionConfig, False] | The code execution config. Either False (no execution) or a dict. |
agent_default_auto_reply | Optional[str] | The agent's default auto reply when no input is received. |
max_consecutive_auto_reply | Optional[int] | The maximum number or consecutive auto replies to use before ending the chat. Default: None (no limit). |
termination | WaldiezAgentTerminationMessage | The message termination check to use (keyword, method, none) |
teachability | WaldiezAgentTeachability | The agent teachability configuration. |
model_ids | List[str] | A list of models (their ids) to link with the agent. |
skills | List[WaldiezAgentLinkedSkill] | A list of skills (id and executor) to register. |
nested_chats | List[WaldiezAgentNestedChat] | A list of nested chats (triggered_by, messages), to register. |
is_multimodal | bool | A flag to indicate if the agent is multimodal. |
Waldiez Agent types.
WaldiezAgentType = Literal['user', 'assistant', 'manager', 'rag_user', 'swarm', 'reasoning', 'captain']
module-attribute
¶
Possible types of a Waldiez Agent: user, assistant, manager, rag_user, swarm, reasoning, captain.
Waldiez Agent Code Execution Configuration.
WaldiezAgentCodeExecutionConfig
¶
Bases: WaldiezBase
Waldiez Agent Code Execution Configuration.
Attributes:
Name | Type | Description |
---|---|---|
work_dir | Optional[str] | The working directory for the code execution. |
use_docker | Optional[bool] | Run the code in a docker container. |
timeout | Optional[float] | The timeout for the code execution. By default None (no timeout). |
last_n_messages | Optional[int] | The chat's last n messages to consider for the code execution. |
functions | Optional[List[str]] | If not using docker, a list of function ids to use. |
Waldiez Agent Skill Model.
WaldiezAgentLinkedSkill
¶
Bases: WaldiezBase
Waldiez Agent Linked Skill.
Attributes:
Name | Type | Description |
---|---|---|
id | str | The id of the skill to use. |
executor_id | str | The id of the agent to use that skill. |
Waldiez Agent Nested Chat.
WaldiezAgentNestedChat
¶
Bases: WaldiezBase
Waldiez Agent Nested Chat.
Attributes:
Name | Type | Description |
---|---|---|
triggered_by | List[str] | A list of agent ids that trigger the nested chat. |
messages | List[WaldiezAgentNestedChatMessage] | The list of messages (chat ids and 'is_reply'z) to include the in the nested chat registration. |
WaldiezAgentNestedChatMessage
¶
Bases: WaldiezBase
Waldiez Agent nested chat message.
A reference to a chat's message or reply in a nested chat
Attributes:
Name | Type | Description |
---|---|---|
id | str | The id of the chat. |
is_reply | bool | Whether to use the reply in the chat or not. |
Waldiez Agent Termination Message Check.
WaldiezAgentTerminationMessage
¶
Bases: WaldiezBase
Waldiez Agent Termination Message Check.
Attributes:
Name | Type | Description |
---|---|---|
type | Literal['none', 'keyword', 'method'] | The type of the termination check to use: "none", "keyword", "method" |
keywords | List[str] | If the type is "keyword", the keywords to search in the message. |
criterion | Optional[Literal["found", "ending", "exact"]] = None | If the type is "keyword", the criterion to use (e.g.: in, endswith, ==) |
method_content | Optional[str] | If the type is "method", the code of the method to use. The method must be called |
string | str | The value of the termination message. |
Methods:
Name | Description |
---|---|
validate_termination_message | Validate the termination message configuration. |
get_termination_function(name_prefix: Optional[str] = None, name_suffix: Optional[str] = None) -> Tuple[str, str]
¶
Get the termination function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_prefix | str | The function name prefix. | None |
name_suffix | str | The function name suffix. | None |
Returns:
Type | Description |
---|---|
Tuple[str, str] | The termination function and the function name. |
Source code in waldiez/models/agents/agent/termination_message.py
string: str
property
¶
Get the value of the termination message.
- If the type is "none", the value is "None".
- If the type is "keyword", the value is a lambda function that checks if any of the keywords comply with the criterion.
- If the type is "method", the value is the method content.
Returns:
Type | Description |
---|---|
str | The value of the termination message. |
validate_termination_message() -> Self
¶
Validate the termination message configuration.
Raises:
Type | Description |
---|---|
ValueError | If the configuration is invalid. |
Returns:
Type | Description |
---|---|
WaldiezAgentTerminationMessage | The validated termination message configuration. |
Source code in waldiez/models/agents/agent/termination_message.py
Waldiez Agent Teachability.
WaldiezAgentTeachability
¶
Bases: WaldiezBase
Waldiez Agent Teachability.
Attributes:
Name | Type | Description |
---|---|---|
enabled | bool | Whether the teachability is enabled. |
verbosity | Literal[0, 1, 2, 3] | The verbosity level of the teachability. Default: 0 |
reset_db | bool | Whether to reset the database. Default: False |
recall_threshold | float | The recall threshold. Default: 1.5 |
max_num_retrievals | int | The maximum number of retrievals. Default: 10 |