New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass Messages to CommonSkill handlers #2875
Comments
What sort of extra data are you interested to pass into the The signature was made like it is to provide a simple interface where the purpose of the arguments are understandable and easy to operate on. If we want to give access to the Message maybe we can make a lowelevel version that can be used in place of the more highlevel versions. for the common playback skill something like: def __handle_play_query(self, message):
"""Query skill if it can start playback from given phrase."""
search_phrase = message.data["phrase"]
# First, notify the requestor that we are attempting to handle
# (this extends a timeout while this skill looks for a match)
self.bus.emit(message.response({"phrase": search_phrase,
"skill_id": self.skill_id,
"searching": True}))
# CALL THE NEW COOL LOW LEVEL METHOD WITH THE MESSAGE
result = self._CPS_low_level_match_query(message)
if result:
match = result[0]
level = result[1]
callback = result[2] if len(result) > 2 else None
confidence = self.__calc_confidence(match, search_phrase, level)
self.bus.emit(message.response({"phrase": search_phrase,
"skill_id": self.skill_id,
"callback_data": callback,
"service_name": self.spoken_name,
"conf": confidence}))
else:
# Signal we are done (can't handle it)
self.bus.emit(message.response({"phrase": search_phrase,
"skill_id": self.skill_id,
"searching": False}))
def _CPS_low_level_match_query(self, message):
return self.CPS_match_query_phrase(message.data['phrase']) So if the complete message object is of interest the Edit: fixed some issues in the code... |
I do see advantages to passing something simple like 'phrase'. My initial thought was actually just to add For the Neon use case that prompted this change for me, we include user data in message objects for our requests to support multiple users. In general, adding params to Message objects helps maintain context throughout the core which I see as a benefit. |
Is there a strong preference from anyone here one way or the other? I like Ake's suggestion as it means less work to maintain backwards comatibility now, though I see adding an extra 'message' param (in addition to phrase) as possibly more logical going forward.. Skill authors would be encouraged to add the param for signatures to match, but wouldn't have to do anything differently to interface |
i like @forslund suggestion! not sure about the naming of the new function, but the implementation looks solid and i would like to see that in all common_XXX frameworks. for the hivemind i often need the message object for proper routing |
Is your feature request related to a problem? Please describe.
Similar to #2812, Messages are easier to write generic methods around so a CommonSkill match method could be easily adapted from an intent handler, more data is available, supporting methods can always expect Messages, etc.
Describe the solution you'd like
Like #2813 resolved #2812, I propose passing messages instead of just text. I think passing the callback data in the action methods does provide some convenience, though that is also included in the message so it would be possible to use messages alone.
Describe alternatives you've considered
There is currently no other means for passing extra data into
match_query_phrase
.action
can receive extra data via thecallback_data
param, though inserting a message into thecallback_data
seems like more of a workaround than a solution.Additional context
None
The text was updated successfully, but these errors were encountered: