Skip to content

Commit

Permalink
feat/common_query_ping
Browse files Browse the repository at this point in the history
add bus messages for common_qa skills to announce themselves
  • Loading branch information
JarbasAl authored Jan 12, 2024
1 parent c8cf18b commit f11a33c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ovos_workshop/skills/common_query_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from ovos_bus_client import Message
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.log import LOG, log_deprecation
from ovos_workshop.skills.ovos import OVOSSkill

from ovos_workshop.decorators.compat import backwards_compat
from ovos_workshop.skills.ovos import OVOSSkill


class CQSMatchLevel(IntEnum):
Expand Down Expand Up @@ -58,14 +59,14 @@ class CommonQuerySkill(OVOSSkill):
answers from several skills presenting the best one available.
"""

def __init__(self, name=None, bus=None, **kwargs):
def __init__(self, *args, **kwargs):
# these should probably be configurable
self.level_confidence = {
CQSMatchLevel.EXACT: 0.9,
CQSMatchLevel.CATEGORY: 0.6,
CQSMatchLevel.GENERAL: 0.5
}
OVOSSkill.__init__(self, name, bus, **kwargs)
super().__init__(*args, **kwargs)

noise_words_filepath = f"text/{self.lang}/noise_words.list"
default_res = f"{dirname(dirname(__file__))}/res/text/{self.lang}" \
Expand Down Expand Up @@ -109,6 +110,15 @@ def bind(self, bus):
speak_errors=False)
self.add_event('question:action', self.__handle_query_action,
speak_errors=False)
self.add_event("ovos.common_query.ping", self.__handle_common_query_ping,
speak_errors=False)
self.__handle_common_query_ping(Message("ovos.common_query.ping"))

# announce skill to ovos-core
def __handle_common_query_ping(self, message):
self.bus.emit(message.reply("ovos.common_query.pong",
{"skill_id": self.skill_id},
{"skill_id": self.skill_id}))

def __handle_question_query(self, message: Message):
"""
Expand Down Expand Up @@ -255,6 +265,7 @@ def __handle_query_action(self, message: Message):
self.CQS_action(phrase, data)
self.bus.emit(message.forward("mycroft.skill.handler.complete",
{"handler": "common_query"}))

@abstractmethod
def CQS_match_query_phrase(self, phrase: str) -> \
Optional[Tuple[str, CQSMatchLevel, Optional[dict]]]:
Expand Down

0 comments on commit f11a33c

Please sign in to comment.