aea.aea_builder

This module contains utilities for building an AEA.

AEABuilder

class AEABuilder()

This class helps to build an AEA.

It follows the fluent interface. Every method of the builder returns the instance of the builder itself.

__init__

 | __init__(with_default_packages: bool = True)

Initialize the builder.

Arguments:

  • with_default_packages: add the default packages.

set_timeout

 | set_timeout(timeout: Optional[float]) -> "AEABuilder"

Set agent loop idle timeout in seconds.

Arguments:

  • timeout: timeout in seconds

Returns:

self

set_execution_timeout

 | set_execution_timeout(execution_timeout: Optional[float]) -> "AEABuilder"

Set agent execution timeout in seconds.

Arguments:

  • execution_timeout: execution_timeout in seconds

Returns:

self

set_max_reactions

 | set_max_reactions(max_reactions: Optional[int]) -> "AEABuilder"

Set agent max reaction in one react.

Arguments:

  • max_reactions: int

Returns:

self

set_decision_maker_handler

 | set_decision_maker_handler(decision_maker_handler_dotted_path: str, file_path: Path) -> "AEABuilder"

Set decision maker handler class.

Arguments:

  • decision_maker_handler_dotted_path: the dotted path to the decision maker handler
  • file_path: the file path to the file which contains the decision maker handler

Returns:

self

set_skill_exception_policy

 | set_skill_exception_policy(skill_exception_policy: Optional[ExceptionPolicyEnum]) -> "AEABuilder"

Set skill exception policy.

Arguments:

  • skill_exception_policy: the policy

Returns:

self

set_default_routing

 | set_default_routing(default_routing: Dict[PublicId, PublicId]) -> "AEABuilder"

Set default routing.

This is a map from public ids (protocols) to public ids (connections).

Arguments:

  • default_routing: the default routing mapping

Returns:

self

set_loop_mode

 | set_loop_mode(loop_mode: Optional[str]) -> "AEABuilder"

Set the loop mode.

Arguments:

  • loop_mode: the agent loop mode

Returns:

self

set_name

 | set_name(name: str) -> "AEABuilder"

Set the name of the agent.

Arguments:

  • name: the name of the agent.

Returns:

the AEABuilder

set_default_connection

 | set_default_connection(public_id: PublicId) -> "AEABuilder"

Set the default connection.

Arguments:

  • public_id: the public id of the default connection package.

Returns:

the AEABuilder

add_private_key

 | add_private_key(identifier: str, private_key_path: PathLike) -> "AEABuilder"

Add a private key path.

Arguments:

  • identifier: the identifier for that private key path.
  • private_key_path: path to the private key file.

Returns:

the AEABuilder

remove_private_key

 | remove_private_key(identifier: str) -> "AEABuilder"

Remove a private key path by identifier, if present.

Arguments:

  • identifier: the identifier of the private key.

Returns:

the AEABuilder

private_key_paths

 | @property
 | private_key_paths() -> Dict[str, str]

Get the private key paths.

add_ledger_api_config

 | add_ledger_api_config(identifier: str, config: Dict) -> "AEABuilder"

Add a configuration for a ledger API to be supported by the agent.

Arguments:

  • identifier: the identifier of the ledger api
  • config: the configuration of the ledger api

Returns:

the AEABuilder

remove_ledger_api_config

 | remove_ledger_api_config(identifier: str) -> "AEABuilder"

Remove a ledger API configuration.

Arguments:

  • identifier: the identifier of the ledger api

Returns:

the AEABuilder

ledger_apis_config

 | @property
 | ledger_apis_config() -> Dict[str, Dict[str, Union[str, int]]]

Get the ledger api configurations.

set_default_ledger

 | set_default_ledger(identifier: str) -> "AEABuilder"

Set a default ledger API to use.

Arguments:

  • identifier: the identifier of the ledger api

Returns:

the AEABuilder

add_component

 | add_component(component_type: ComponentType, directory: PathLike, skip_consistency_check: bool = False) -> "AEABuilder"

Add a component, given its type and the directory.

Arguments:

  • component_type: the component type.
  • directory: the directory path.
  • skip_consistency_check: if True, the consistency check are skipped.

Raises:

  • AEAException: if a component is already registered with the same component id. | or if there's a missing dependency.

Returns:

the AEABuilder

add_component_instance

 | add_component_instance(component: Component) -> "AEABuilder"

Add already initialized component object to resources or connections.

Please, pay attention, all dependencies have to be already loaded.

:params component: Component instance already initialized.

set_context_namespace

 | set_context_namespace(context_namespace: Dict[str, Any]) -> "AEABuilder"

Set the context namespace.

remove_component

 | remove_component(component_id: ComponentId) -> "AEABuilder"

Remove a component.

Arguments:

  • component_id: the public id of the component.

Returns:

the AEABuilder

add_protocol

 | add_protocol(directory: PathLike) -> "AEABuilder"

Add a protocol to the agent.

Arguments:

  • directory: the path to the protocol directory

Returns:

the AEABuilder

remove_protocol

 | remove_protocol(public_id: PublicId) -> "AEABuilder"

Remove protocol.

Arguments:

  • public_id: the public id of the protocol

Returns:

the AEABuilder

add_connection

 | add_connection(directory: PathLike) -> "AEABuilder"

Add a connection to the agent.

Arguments:

  • directory: the path to the connection directory

Returns:

the AEABuilder

remove_connection

 | remove_connection(public_id: PublicId) -> "AEABuilder"

Remove a connection.

Arguments:

  • public_id: the public id of the connection

Returns:

the AEABuilder

add_skill

 | add_skill(directory: PathLike) -> "AEABuilder"

Add a skill to the agent.

Arguments:

  • directory: the path to the skill directory

Returns:

the AEABuilder

remove_skill

 | remove_skill(public_id: PublicId) -> "AEABuilder"

Remove protocol.

Arguments:

  • public_id: the public id of the skill

Returns:

the AEABuilder

add_contract

 | add_contract(directory: PathLike) -> "AEABuilder"

Add a contract to the agent.

Arguments:

  • directory: the path to the contract directory

Returns:

the AEABuilder

remove_contract

 | remove_contract(public_id: PublicId) -> "AEABuilder"

Remove protocol.

Arguments:

  • public_id: the public id of the contract

Returns:

the AEABuilder

build

 | build(connection_ids: Optional[Collection[PublicId]] = None, ledger_apis: Optional[LedgerApis] = None) -> AEA

Build the AEA.

Arguments:

  • connection_ids: select only these connections to run the AEA.
  • ledger_apis: the api ledger that we want to use.

Returns:

the AEA object.

from_aea_project

 | @classmethod
 | from_aea_project(cls, aea_project_path: PathLike, skip_consistency_check: bool = False) -> "AEABuilder"

Construct the builder from an AEA project.

  • load agent configuration file
  • set name and default configurations
  • load private keys
  • load ledger API configurations
  • set default ledger
  • load every component

Arguments:

  • aea_project_path: path to the AEA project.
  • skip_consistency_check: if True, the consistency check are skipped.

Returns:

an AEABuilder.