diff --git a/__init__.py b/__init__.py index 54516db..9185730 100644 --- a/__init__.py +++ b/__init__.py @@ -40,20 +40,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from neon_utils.skills.neon_fallback_skill import NeonFallbackSkill -from neon_utils.message_utils import neon_must_respond, request_for_neon +from ovos_workshop.decorators import fallback_handler +from ovos_workshop.skills.fallback import FallbackSkill +from neon_utils.message_utils import request_for_neon from ovos_bus_client import Message from ovos_utils import classproperty from ovos_utils.log import LOG from ovos_utils.process_utils import RuntimeRequirements -class UnknownSkill(NeonFallbackSkill): - def __init__(self, *args, **kwargs): - NeonFallbackSkill.__init__(self, *args, **kwargs) - self.register_fallback(self.handle_fallback, 100) - # Set of clients that always expect a response - self._transactional_clients = {"mq_api"} +class UnknownSkill(FallbackSkill): + # Set of clients that always expect a response + _transactional_clients = {"mq_api", "klat", "mobile"} @classproperty def runtime_requirements(self): @@ -76,6 +74,7 @@ def _read_voc_lines(self, name) -> filter: with open(self.find_resource(name + '.voc', 'vocab')) as f: return filter(bool, map(str.strip, f.read().split('\n'))) + @fallback_handler(priority=100) def handle_fallback(self, message: Message): LOG.info("Unknown Fallback Checking for Neon!!!") utterance = message.data['utterance'] @@ -84,7 +83,6 @@ def handle_fallback(self, message: Message): True) # This checks if we're pretty sure this was a request intended for Neon if not any((request_for_neon(message, "neon", self.voc_match, ww_state), - neon_must_respond(message), client in self._transactional_clients)): LOG.info("Ignoring streaming STT or public conversation input") return True @@ -103,15 +101,14 @@ def handle_fallback(self, message: Message): # Show utterance that failed to match an intent if self.settings.get('show_utterances'): self.gui['utterance'] = utterance - self.gui.show_page("UnknownIntent.qml") + self.gui.show_page("UnknownIntent") + + # Report an intent failure + self.bus.emit(Message("neon.metric", {"name": "failed-intent", + 'utterance': utterance, + 'client': client + })) - try: - # Report an intent failure - self.report_metric('failed-intent', - {'utterance': utterance, - 'device': self.config_core.get("dev_type")}) - except Exception as e: - LOG.exception(e) LOG.debug(f"Checking if neon must respond: {message.data}") # Determine what kind of question this is to reply appropriately diff --git a/requirements.txt b/requirements.txt index 056147f..dba51c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ neon-utils~=1.5 -ovos_utils~=0.0.28 \ No newline at end of file +ovos_utils~=0.0.28 +ovos-workshop~=0.0.15 \ No newline at end of file diff --git a/skill.json b/skill.json index 1f98403..ccbc9ec 100644 --- a/skill.json +++ b/skill.json @@ -11,6 +11,7 @@ "requirements": { "python": [ "neon-utils~=1.5", + "ovos-workshop~=0.0.15", "ovos_utils~=0.0.28" ], "system": {}, diff --git a/test/test_skill.py b/test/test_skill.py index f3defaa..e9e2060 100644 --- a/test/test_skill.py +++ b/test/test_skill.py @@ -41,11 +41,6 @@ class TestSkill(SkillTestCase): - def test_00_skill_init(self): - from neon_utils.skills.neon_skill import NeonSkill - self.assertIsInstance(self.skill, NeonSkill) - self.assertIsInstance(self.skill, NeonFallbackSkill) - def test_read_voc_lines(self): valid_vocab = ('question', 'who.is', 'why.is') for v in valid_vocab: