aea.skills.base
This module contains the base classes for the skills.
SkillContext Objects
This class implements the context of a skill.
__
init__
Initialize a skill context.
Arguments:
agent_context
: the agent context.skill
: the skill.
logger
Get the logger.
logger
Set the logger.
set_
agent_
context
Set the agent context.
shared_
state
Get the shared state dictionary.
agent_
name
Get agent name.
skill_
id
Get the skill id of the skill context.
is_
active
Get the status of the skill (active/not active).
is_
active
Set the status of the skill (active/not active).
new_
behaviours
Queue for the new behaviours.
This queue can be used to send messages to the framework to request the registration of a behaviour.
Returns:
the queue of new behaviours.
new_
handlers
Queue for the new handlers.
This queue can be used to send messages to the framework to request the registration of a handler.
Returns:
the queue of new handlers.
agent_
addresses
Get addresses.
agent_
address
Get address.
public_
key
Get public key.
public_
keys
Get public keys.
connection_
status
Get connection status.
outbox
Get outbox.
storage
Get optional storage for agent.
message_
in_
queue
Get message in queue.
decision_
maker_
message_
queue
Get message queue of decision maker.
decision_
maker_
handler_
context
Get decision maker handler context.
task_
manager
Get behaviours of the skill.
default_
ledger_
id
Get the default ledger id.
currency_
denominations
Get a dictionary mapping ledger ids to currency denominations.
search_
service_
address
Get the address of the search service.
decision_
maker_
address
Get the address of the decision maker.
handlers
Get handlers of the skill.
behaviours
Get behaviours of the skill.
namespace
Get the agent context namespace.
__
getattr__
Get attribute.
send_
to_
skill
| send_to_skill(message_or_envelope: Union[Message, Envelope], context: Optional[EnvelopeContext] = None) -> None
Send message or envelope to another skill.
If message passed it will be wrapped into envelope with optional envelope context.
Arguments:
message_or_envelope
: envelope to send to another skill.context
: the optional envelope context
SkillComponent Objects
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.kwargs
: the keyword arguments.
name
Get the name of the skill component.
context
Get the context of the skill component.
skill_
id
Get the skill id of the skill component.
configuration
Get the skill component configuration.
config
Get the config of the skill component.
setup
Implement the setup.
teardown
Implement the teardown.
parse_
module
| @classmethod
| @abstractmethod
| parse_module(cls, path: str, configs: Dict[str, SkillComponentConfiguration], skill_context: SkillContext) -> dict
Parse the component module.
AbstractBehaviour Objects
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
Get the tick_interval in seconds.
start_
at
Get the start time of the behaviour.
Behaviour Objects
This class implements an abstract behaviour.
In a subclass of Behaviour, the flag 'is_programmatically_defined' can be used by the developer to signal to the framework that the class is meant to be used programmatically; hence, in case the class is not declared in the configuration file but it is present in a skill module, the framework will just ignore this class instead of printing a warning message.
act
Implement the behaviour.
Returns:
None
is_
done
Return True if the behaviour is terminated, False otherwise.
act_
wrapper
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
This class implements an abstract behaviour.
In a subclass of Handler, the flag 'is_programmatically_defined' can be used by the developer to signal to the framework that the component is meant to be used programmatically; hence, in case the class is not declared in the configuration file but it is present in a skill module, the framework will just ignore this class instead of printing a warning message.
SUPPORTED_PROTOCOL is read by the framework when the handlers are loaded to register them as 'listeners' to the protocol identified by the specified public id. Whenever a message of protocol 'SUPPORTED_PROTOCOL' is sent to the agent, the framework will call the 'handle' method.
handle
Implement the reaction to a message.
Arguments:
message
: the message
Returns:
None
handle_
wrapper
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
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 notkwargs
: the keyword arguments.
setup
Set the class up.
teardown
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 model 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
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.kwargs
: the keyword arguments.
skill_
context
Get the skill context.
handlers
Get the handlers.
behaviours
Get the handlers.
models
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.kwargs
: the keyword arguments.
Returns:
the skill object.
logger
Get the logger.
In the case of a skill, return the logger provided by the skill context.
Returns:
the logger
logger
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.kwargs
: the keyword arguments.
Returns:
the skill.
_
SkillComponentLoadingItem Objects
Class to represent a triple (component name, component configuration, component class).
__
init__
| __init__(name: str, config: SkillComponentConfiguration, class_: Type[SkillComponent], type_: _SKILL_COMPONENT_TYPES)
Initialize the item.
_
SkillComponentLoader Objects
This class implements the loading policy for skill components.
__
init__
Initialize the helper class.
load_
skill
Load the skill.