Skip to content

Commit

Permalink
feat/pipeline_session (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Sep 22, 2023
1 parent 7b8a42e commit 763c36f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
30 changes: 9 additions & 21 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 763c36f

Please sign in to comment.