Execute
A Skill performs its intended function when it is executed, and execution may entail interacting with the real world. When executed, the Skill is provided an initial world state and a parameter set. The parameter set is a set of named and typed values passed into the Skill from the process in which it exists. The names and types of the parameter set must match those specified by the Skill developer.
Prerequisites
Before attempting this guide, you must:
- Deploy a solution
- Set up your development environment
- Connect VS Code to your cloud organization
- Know how to create skills
- Understand the skill interface
Purpose
The primary purpose of Skill.execute() is to encapsulate the actions a Skill performs, which may include:
- Using the given world state and parameter set as input to actions related to the skill.
- Using Flowstate Services to facilitate the actions.
- Generating output data that reflect the outcome of the Skill's execution.
By implementing this method, you define the "what" and "how" of your skill's behavior.
Args
The execute method takes two arguments:
ExecuteRequest: input toSkill.execute(), containing the parameter set.ExecuteContext: additional conext needed to access the world state, as well as other Services that the Skill may use.
Return Value
The execute() method should either return a result proto message, which is defined by the Skill developer, or None if the Skill does not provide a result.
If you look inside skill_interface.py, you can see that the return type of the execute() method is TResultType (where TResultType = TypeVar('TResultType', bound=Union[message.Message, None])), allowing for either the user defined type or None.