Thanks @JarbasAl, useful comments. (I like your tutorial, wish I had found it earlier!)
from the community we have 2 main meta/bridge skills, home assistant and node red, these will interact with other software and fit your description above
The advantage of these frameworks is that once there is a skill for them, then anything running under that framework is available to Mycroft. I gather from the recent CES that vendors are now starting to write to some of the frameworks, so the number of services available to Mycroft (and Alexa and Google Assistant…) will steadily increase. But using a framework won’t be everyone’s choice.
regarding audio playback the playback control skill will handle next/previous/stop/resume, play is the only intent that really needs to ask individual skills which one can do it
Yes, my mistake - I hadn’t thought it through.
you got it a bit wrong with the “can this skill run?” , skills that maybe can run will register themselves, so the question is actually “how well can you solve this thing you said you usually can?”
Yes, I stand corrected, thanks. Can I rephrase this as “given the syntax matches (to high confidence), will the semantics match (to what confidence)?” The vocabulary should have been chosen so that the confidence level is high, but not a guarantee.
What the Common X Skills seems to be adding is a semantic layer to the syntactic pattern matching of Adapt. This is done without altering the Mycroft core code at all. What I was experimenting with was changing the Mycroft core code to add in semantic tests. Obviously that has to be done so that it doesn’t break any existing systems nor cause any time blowouts in execution.
I guess my question would be: is that worthwhile exploring, or is the current core considered off-limits? Or maybe it has been tried already?
The current algorithm in Mycroft is basically
best intent = None
for each matching intent
update best intent
if best intent != None
execute intent
return
execute fallback skills
I’ve prototyped changing this to
matching intent list = []
for each matching intent (> some confidence)
add to matching intent list
sort matching intent list
for each intent in matching intent list
execute intent
if execution failed
continue with next intent
else
exit
execute fallback skills
Success or failure can be tested for a return value of None or otherwise from a method - current intents return no value (i.e. None) so no change is needed to signal success. (I see that the fallback skills return True or False in a similar way.). So current systems will not be broken.
The changes to the Mycroft code are not extensive. Return an ordered list from determine_intent() instead of a singleton, put success or failure on the bus from wrapper() in core.py. This is caught in handle_utterance() and will get another intent from determine_intent() if needed. The time cost is sorting and an extra bus message. Sorting is pretty efficient anyway in Python, but if needed a lazy sort could be used, as described by Lazy sorting in Python For current skills, they all succeed, so only the best intent will be tried, an O(1) cost in trying intents. This cost only increases if skills that fail are tried.
Following the ideas of the Common X systems, maybe a combination of adding a semantic assessment to the core might be better:
matching intent list = []
for each matching intent
add to best matching intent list
can succeed list = []
for each intent in matching intent list
if intent can succeed (above some threshold),
add to can succeed list
for each intent in can succeed list (maybe sorted?)
execute intent
if execution failed
continue with next intent
else
exit
execute fallback skills
I’m assuming “can succeed” returns a confidence level 0.0 - 1.0 like CommonQuery. This isn’t as finegrained as CommonPlay - which can still be used, none of the existing skills will be affected.
If MycroftSkill has an added method of can_succeed() returning 1.0, then only classes overriding this signal possible inability to handle an utterance. So existing intents with no changes work exactly as before. The extra time cost for existing skills will be the round trip to evaluate the default value of 1.0 and an intent with that value will of course be executed (and should succeed). This is in addition to the sorting and extra bus traffic of the previous code.
So, is it worth experimenting or should I give up on this?