From 27d891edc40edc2b5ca2a8aee1e598877dc829f3 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 18 Oct 2024 06:55:51 +0100 Subject: [PATCH] fix:fallback match (#572) * fix:fallback match the priority levels were not being respected, everything matched under fallback_high * fix tests --- ovos_core/intent_services/fallback_service.py | 9 ++++++--- test/end2end/session/test_fallback.py | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ovos_core/intent_services/fallback_service.py b/ovos_core/intent_services/fallback_service.py index ce567ada341..b4374a56b7e 100644 --- a/ovos_core/intent_services/fallback_service.py +++ b/ovos_core/intent_services/fallback_service.py @@ -98,17 +98,20 @@ def _collect_fallback_skills(self, message: Message, def handle_ack(msg): skill_id = msg.data["skill_id"] if msg.data.get("can_handle", True): - if skill_id in self.registered_fallbacks: + if skill_id in in_range: fallback_skills.append(skill_id) - LOG.info(f"{skill_id} will try to handle fallback") + LOG.info(f"{skill_id} will try to handle fallback") + else: + LOG.debug(f"{skill_id} is out of range, skipping") else: - LOG.info(f"{skill_id} will NOT try to handle fallback") + LOG.debug(f"{skill_id} does NOT WANT to try to handle fallback") skill_ids.append(skill_id) if in_range: # no need to search if no skills available self.bus.on("ovos.skills.fallback.pong", handle_ack) LOG.info("checking for FallbackSkillsV2 candidates") + message.data["range"] = (fb_range.start, fb_range.stop) # wait for all skills to acknowledge they want to answer fallback queries self.bus.emit(message.forward("ovos.skills.fallback.ping", message.data)) diff --git a/test/end2end/session/test_fallback.py b/test/end2end/session/test_fallback.py index facdaba0667..0aca1e32fdf 100644 --- a/test/end2end/session/test_fallback.py +++ b/test/end2end/session/test_fallback.py @@ -349,7 +349,7 @@ def wait_for_n_messages(n): # confirm all expected messages are sent expected_messages = [ "recognizer_loop:utterance", - # FallbackV2 + # Fallback High "ovos.skills.fallback.ping", "ovos.skills.fallback.pong", "ovos.skills.fallback.pong", @@ -361,6 +361,11 @@ def wait_for_n_messages(n): f"ovos.skills.fallback.{self.skill_id2}.response", f"ovos.skills.fallback.{self.skill_id2}.killed", # killable_event decorator response + # Fallback Medium + "ovos.skills.fallback.ping", + "ovos.skills.fallback.pong", + "ovos.skills.fallback.pong", + # skill executing f"ovos.skills.fallback.{self.skill_id}.request", f"ovos.skills.fallback.{self.skill_id}.start",