Skill Usage Guide¶
Using a Skill in a PyRaya Application is a straightforward process. Once the Skill is available in the application’s directory, it can be imported, registered, and executed from any custom PyRaya application.
Note
An application that extends RayaApplicationBase continues to behave the
same way when Skills are used. Skills simply provide additional modular
functionality and do not alter the structure or behavior of the base
application.
Importing the Skill¶
Once a Skill is placed under the application’s skills/ directory, it can be imported normally. For example:
from skills import SkillName
Registering the Skill¶
Before using a Skill, it must be registered using the register_skill()
method. This creates a handler that manages the Skill instance
and its execution.
self.skill = self.register_skill(SkillName)
This returns a RayaSkillHandler object, which will be used to invoke
the Skill methods.
Setting Up the Skill¶
It is recommended to execute the Skill’s setup method during the application
setup. This is done using execute_setup(), passing in an instance
of the Skill’s SetupArgsModel.
result = await self.skill.execute_setup(
setup_args=SkillSound.SetupArgsModel(),
callback_done=self.on_skill_done,
callback_feedback=self.on_skill_feedback,
wait=True
)
The setup_args must always be an instance of the corresponding SetupArgsModel defined inside the Skill.
- Optional parameters include:
callback_done: function to call once setup is complete.callback_feedback: function to receive feedback from the Skill (if any).wait: ifTrue, the application waits for the setup to complete.
Executing the Skill¶
Executing the Skill is similar to setup and follows the same interface:
result = await self.skill.execute_main(
execute_args=SkillSound.ExecuteArgsModel(),
callback_done=self.on_skill_done,
callback_feedback=self.on_skill_feedback,
wait=True
)
The execute_args must be an instance of the Skill’s ExecuteArgsModel.
Skill Types Compatibility¶
This usage flow is the same for both standard Skills and FSM-based Skills. The developer does not need to modify the usage pattern depending on the type.