Friday
Friday copied to clipboard
Priority system
Description
Currently, plugins return boolean True and False values when given the request and the state of the assistant. This boolean value determines whether the plugin will be executed with the given input. For example, if you have a calendar plugin that only activates when the user references adding an event, then the can_perform
function would return True when the user's request matches your criteria and False all other times.
With this system, it's easy to foresee an eventuality in which multiple plugins return True and the system has to decide between unique responses from each plugin. In that case, my proposed solution would be that instead of returning boolean True and False values, instead the plugins return an integer value determining their 'enthusiasm', so to speak. The plugin which returns the most enthusiasm would have its response selected above all others.
By using this system, alerts and errors can ensure that they will be displayed, more important plugins can ensure that they get the first say when they need to, and thanks to Python's flexible conditional checks, current plugins are not broken under this system. All existing plugins just have a low priority of either 1 or 0 under this system, which means they'd have to be altered slightly to take advantage of the new system, but nothing will be broken before that happens.
What needs to be done
- Adjust the plugin system to work with comparing integer values in the event of a conflict of interest
- Adjust plugins to start returning integer values instead of boolean values
- Lay down ground rules for how plugins should behave (We don't want one plugin overruling all other plugins for no good reason)