From 763c36feba5d18852d020d72b3c4fa74188467fa Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Fri, 22 Sep 2023 21:31:28 +0100 Subject: [PATCH] feat/pipeline_session (#352) --- ovos_core/intent_services/__init__.py | 30 ++++++++------------------- requirements/requirements.txt | 2 +- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index 5c26cace448..98bccaa7932 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -103,22 +103,6 @@ def __init__(self, bus): self.bus.on('intent.service.padatious.entities.manifest.get', self.handle_entity_manifest) - @property - def pipeline(self): - # List of functions to use to match the utterance with intent, listed in priority order. - config = Configuration().get("intents") or {} - return config.get("pipeline", [ - "converse", - "padacioso_high", - "adapt", - "common_qa", - "fallback_high", - "padacioso_medium", - "fallback_medium", - "padacioso_low", - "fallback_low" - ]) - @property def registered_intents(self): lang = get_message_lang() @@ -211,16 +195,17 @@ def disambiguate_lang(message): return default_lang - def get_pipeline(self, skips=None): + def get_pipeline(self, skips=None, session=None): """return a list of matcher functions ordered by priority utterances will be sent to each matcher in order until one can handle the utterance the list can be configured in mycroft.conf under intents.pipeline, in the future plugins will be supported for users to define their own pipeline""" + session = session or SessionManager.get() # Create matchers # TODO - from plugins if self.padatious_service is None: - if any("padatious" in p for p in self.pipeline): + if any("padatious" in p for p in session.pipeline): LOG.warning("padatious is not available! using padacioso in it's place") padatious_matcher = self.padacioso_service else: @@ -242,7 +227,7 @@ def get_pipeline(self, skips=None): "fallback_low": self.fallback.low_prio } skips = skips or [] - pipeline = [k for k in self.pipeline if k not in skips] + pipeline = [k for k in session.pipeline if k not in skips] return [matchers[k] for k in pipeline] def handle_utterance(self, message): @@ -292,7 +277,8 @@ def handle_utterance(self, message): match = None with stopwatch: # Loop through the matching functions until a match is found. - for match_func in self.get_pipeline(): + sess = SessionManager.get(message) + for match_func in self.get_pipeline(session=sess): match = match_func(utterances, lang, message) if match: break @@ -429,12 +415,14 @@ def handle_get_intent(self, message): """ utterance = message.data["utterance"] lang = get_message_lang(message) + sess = SessionManager.get(message) # Loop through the matching functions until a match is found. for match_func in self.get_pipeline(skips=["converse", "fallback_high", "fallback_medium", - "fallback_low"]): + "fallback_low"], + session=sess): match = match_func([utterance], lang, message) if match: if match.intent_type: diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 3bd41726c50..cc4c4736b48 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -6,7 +6,7 @@ combo-lock>=0.2.2, <0.3 padacioso~=0.2, >=0.2.1a8 adapt-parser>=1.0.0, <2.0.0 -ovos_bus_client<0.0.6a1, >=0.0.5 +ovos_bus_client~=0.0,>=0.0.6a7 ovos-utils<0.1.0, >=0.0.35a7 ovos-plugin-manager<0.1.0, >=0.0.24a5 ovos-config~=0.0,>=0.0.11a9