aea.skills.base
This module contains the base classes for the skills.
SkillContext Objects
class SkillContext()
This class implements the context of a skill.
__
init__
| __init__(agent_context: Optional[AgentContext] = None, skill: Optional["Skill"] = None) -> None
Initialize a skill context.
:agent_context: the agent context. :skill: the skill.
logger
| @property
| logger() -> Logger
Get the logger.
logger
| @logger.setter
| logger(logger_: Logger) -> None
Set the logger.
set_
agent_
context
| set_agent_context(agent_context: AgentContext) -> None
Set the agent context.
shared_
state
| @property
| shared_state() -> Dict[str, Any]
Get the shared state dictionary.
agent_
name
| @property
| agent_name() -> str
Get agent name.
skill_
id
| @property
| skill_id() -> PublicId
Get the skill id of the skill context.
is_
active
| @property
| is_active() -> bool
Get the status of the skill (active/not active).
is_
active
| @is_active.setter
| is_active(value: bool) -> None
Set the status of the skill (active/not active).
new_
behaviours
| @property
| new_behaviours() -> "Queue[Behaviour]"
Queue for the new behaviours.
This queue can be used to send messages to the framework to request the registration of a behaviour.
:return the queue of new behaviours.
new_
handlers
| @property
| new_handlers() -> "Queue[Handler]"
Queue for the new handlers.
This queue can be used to send messages to the framework to request the registration of a handler.
:return the queue of new handlers.
agent_
addresses
| @property
| agent_addresses() -> Dict[str, str]
Get addresses.
agent_
address
| @property
| agent_address() -> str
Get address.
connection_
status
| @property
| connection_status() -> MultiplexerStatus
Get connection status.
outbox
| @property
| outbox() -> OutBox
Get outbox.
storage
| @property
| storage() -> Optional[Storage]
Get optional storage for agent.
message_
in_
queue
| @property
| message_in_queue() -> Queue
Get message in queue.
decision_
maker_
message_
queue
| @property
| decision_maker_message_queue() -> Queue
Get message queue of decision maker.
decision_
maker_
handler_
context
| @property
| decision_maker_handler_context() -> SimpleNamespace
Get decision maker handler context.
task_
manager
| @property
| task_manager() -> TaskManager
Get behaviours of the skill.
default_
ledger_
id
| @property
| default_ledger_id() -> str
Get the default ledger id.
currency_
denominations
| @property
| currency_denominations() -> Dict[str, str]
Get a dictionary mapping ledger ids to currency denominations.
search_
service_
address
| @property
| search_service_address() -> Address
Get the address of the search service.
decision_
maker_
address
| @property
| decision_maker_address() -> Address
Get the address of the decision maker.
handlers
| @property
| handlers() -> SimpleNamespace
Get handlers of the skill.
behaviours
| @property
| behaviours() -> SimpleNamespace
Get behaviours of the skill.
namespace
| @property
| namespace() -> SimpleNamespace
Get the agent context namespace.
__
getattr__
| __getattr__(item: Any) -> Any
Get attribute.
SkillComponent Objects
class SkillComponent(ABC)
This class defines an abstract interface for skill component classes.
__
init__
| __init__(name: str, skill_context: SkillContext, configuration: Optional[SkillComponentConfiguration] = None, **kwargs: Any, ,) -> None
Initialize a skill component.
Arguments:
name
: the name of the component.configuration
: the configuration for the component.skill_context
: the skill context.
name
| @property
| name() -> str
Get the name of the skill component.
context
| @property
| context() -> SkillContext
Get the context of the skill component.
skill_
id
| @property
| skill_id() -> PublicId
Get the skill id of the skill component.
configuration
| @property
| configuration() -> SkillComponentConfiguration
Get the skill component configuration.
config
| @property
| config() -> Dict[Any, Any]
Get the config of the skill component.
setup
| @abstractmethod
| setup() -> None
Implement the setup.
Returns:
None
teardown
| @abstractmethod
| teardown() -> None
Implement the teardown.
Returns:
None
parse_
module
| @classmethod
| @abstractmethod
| parse_module(cls, path: str, configs: Dict[str, SkillComponentConfiguration], skill_context: SkillContext) -> dict
Parse the component module.
AbstractBehaviour Objects
class AbstractBehaviour(SkillComponent, ABC)
Abstract behaviour for periodical calls.
tick_interval: float, interval to call behaviour's act. start_at: optional datetime, when to start periodical calls.
tick_
interval
| @property
| tick_interval() -> float
Get the tick_interval in seconds.
start_
at
| @property
| start_at() -> Optional[datetime.datetime]
Get the start time of the behaviour.
Behaviour Objects
class Behaviour(AbstractBehaviour, ABC)
This class implements an abstract behaviour.
act
| @abstractmethod
| act() -> None
Implement the behaviour.
Returns:
None
is_
done
| is_done() -> bool
Return True if the behaviour is terminated, False otherwise.
act_
wrapper
| act_wrapper() -> None
Wrap the call of the action. This method must be called only by the framework.
parse_
module
| @classmethod
| parse_module(cls, path: str, behaviour_configs: Dict[str, SkillComponentConfiguration], skill_context: SkillContext) -> Dict[str, "Behaviour"]
Parse the behaviours module.
Arguments:
path
: path to the Python module containing the Behaviour classes.behaviour_configs
: a list of behaviour configurations.skill_context
: the skill context
Returns:
a list of Behaviour.
Handler Objects
class Handler(SkillComponent, ABC)
This class implements an abstract behaviour.
handle
| @abstractmethod
| handle(message: Message) -> None
Implement the reaction to a message.
Arguments:
message
: the message
Returns:
None
handle_
wrapper
| handle_wrapper(message: Message) -> None
Wrap the call of the handler. This method must be called only by the framework.
parse_
module
| @classmethod
| parse_module(cls, path: str, handler_configs: Dict[str, SkillComponentConfiguration], skill_context: SkillContext) -> Dict[str, "Handler"]
Parse the handler module.
Arguments:
path
: path to the Python module containing the Handler class.handler_configs
: the list of handler configurations.skill_context
: the skill context
Returns:
an handler, or None if the parsing fails.
Model Objects
class Model(SkillComponent, ABC)
This class implements an abstract model.
__
init__
| __init__(name: str, skill_context: SkillContext, configuration: Optional[SkillComponentConfiguration] = None, keep_terminal_state_dialogues: Optional[bool] = None, **kwargs: Any, ,) -> None
Initialize a model.
Arguments:
name
: the name of the component.configuration
: the configuration for the component.skill_context
: the skill context.keep_terminal_state_dialogues
: specify do dialogues in terminal state should stay or not
Returns:
None
setup
| setup() -> None
Set the class up.
teardown
| teardown() -> None
Tear the class down.
parse_
module
| @classmethod
| parse_module(cls, path: str, model_configs: Dict[str, SkillComponentConfiguration], skill_context: SkillContext) -> Dict[str, "Model"]
Parse the tasks module.
Arguments:
path
: path to the Python skill module.model_configs
: a list of model configurations.skill_context
: the skill context
Returns:
a list of Model.
Skill Objects
class Skill(Component)
This class implements a skill.
__
init__
| __init__(configuration: SkillConfig, skill_context: Optional[SkillContext] = None, handlers: Optional[Dict[str, Handler]] = None, behaviours: Optional[Dict[str, Behaviour]] = None, models: Optional[Dict[str, Model]] = None, **kwargs: Any, ,)
Initialize a skill.
Arguments:
configuration
: the skill configuration.skill_context
: the skill context.handlers
: dictionary of handlers.behaviours
: dictionary of behaviours.models
: dictionary of models.
skill_
context
| @property
| skill_context() -> SkillContext
Get the skill context.
handlers
| @property
| handlers() -> Dict[str, Handler]
Get the handlers.
behaviours
| @property
| behaviours() -> Dict[str, Behaviour]
Get the handlers.
models
| @property
| models() -> Dict[str, Model]
Get the handlers.
from_
dir
| @classmethod
| from_dir(cls, directory: str, agent_context: AgentContext, **kwargs: Any) -> "Skill"
Load the skill from a directory.
Arguments:
directory
: the directory to the skill package.agent_context
: the skill context
Returns:
the skill object.
logger
| @property
| logger() -> Logger
Get the logger.
In the case of a skill, return the logger provided by the skill context.
logger
| @logger.setter
| logger(*args: str) -> None
Set the logger.
from_
config
| @classmethod
| from_config(cls, configuration: SkillConfig, agent_context: AgentContext, **kwargs: Any) -> "Skill"
Load the skill from configuration.
Arguments:
configuration
: a skill configuration. Must be associated with a directory.agent_context
: the agent context.
Returns:
the skill.