Skip to content

Commit

Permalink
fix utterance missing
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jul 7, 2023
1 parent 62d3822 commit bcc3061
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 395 deletions.
4 changes: 3 additions & 1 deletion ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# skill_id: the skill this handler belongs to
IntentMatch = namedtuple('IntentMatch',
['intent_service', 'intent_type',
'intent_data', 'skill_id']
'intent_data', 'skill_id', 'utterance']
)


Expand Down Expand Up @@ -264,6 +264,8 @@ def handle_utterance(self, message):
if match:
break
if match:
message.data["utterance"] = match.utterance

if match.skill_id:
self.converse.activate_skill(match.skill_id)
# If the service didn't report back the skill_id it
Expand Down
3 changes: 2 additions & 1 deletion ovos_core/intent_services/adapt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def take_best(intent, utt):
self.update_context(best_intent)
skill_id = best_intent['intent_type'].split(":")[0]
ret = ovos_core.intent_services.IntentMatch(
'Adapt', best_intent['intent_type'], best_intent, skill_id
'Adapt', best_intent['intent_type'], best_intent, skill_id,
best_intent['utterance']
)
else:
ret = None
Expand Down
2 changes: 1 addition & 1 deletion ovos_core/intent_services/commonqa_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def match(self, utterances, lang, message):
message.data["utterance"] = utterance
answered = self.handle_question(message)
if answered:
match = ovos_core.intent_services.IntentMatch('CommonQuery', None, {}, None)
match = ovos_core.intent_services.IntentMatch('CommonQuery', None, {}, None, utterance)
break
return match

Expand Down
2 changes: 1 addition & 1 deletion ovos_core/intent_services/converse_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,5 @@ def converse_with_skills(self, utterances, lang, message):
# check if any skill wants to handle utterance
for skill_id in self._collect_converse_skills():
if self.converse(utterances, skill_id, lang, message):
return ovos_core.intent_services.IntentMatch('Converse', None, None, skill_id)
return ovos_core.intent_services.IntentMatch('Converse', None, None, skill_id, utterances[0])
return None
4 changes: 2 additions & 2 deletions ovos_core/intent_services/fallback_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _fallback_range(self, utterances, lang, message, fb_range):
for skill_id, prio in sorted_handlers:
result = self.attempt_fallback(utterances, skill_id, lang, message)
if result:
return ovos_core.intent_services.IntentMatch('Fallback', None, {}, None)
return ovos_core.intent_services.IntentMatch('Fallback', None, {}, None, utterances[0])

# old style deprecated fallback skill singleton class
LOG.debug("checking for FallbackSkillsV1")
Expand All @@ -178,7 +178,7 @@ def _fallback_range(self, utterances, lang, message, fb_range):
response = self.bus.wait_for_response(msg, timeout=10)

if response and response.data['handled']:
return ovos_core.intent_services.IntentMatch('Fallback', None, {}, None)
return ovos_core.intent_services.IntentMatch('Fallback', None, {}, None, utterances[0])
return None

def high_prio(self, utterances, lang, message):
Expand Down
11 changes: 5 additions & 6 deletions ovos_core/intent_services/padatious_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _match_level(self, utterances, limit, lang=None):
skill_id = padatious_intent.name.split(':')[0]
return ovos_core.intent_services.IntentMatch(
'Padatious', padatious_intent.name,
padatious_intent.matches, skill_id)
padatious_intent.matches, skill_id, padatious_intent.sent)

def match_high(self, utterances, lang=None, message=None):
"""Intent matcher for high confidence.
Expand Down Expand Up @@ -331,10 +331,11 @@ def calc_intent(self, utterances: List[str], lang: str = None) -> Optional[Padat
pool.close()
pool.join()
else:
intents = (_calc_padatious_intent(utt, intent_container) for utt in utterances)
intents = [_calc_padatious_intent(utt, intent_container) for utt in utterances]

# select best
return max(intents, key=lambda k: k.conf)
if intents:
return max(intents, key=lambda k: k.conf)


@lru_cache(maxsize=10) # repeat calls under different conf levels wont re-run code
Expand All @@ -358,9 +359,7 @@ def _calc_padatious_intent(*args) -> \
intent = PadatiousIntent(**intent)
else:
intent.sent = utt
# TODO: This is for backwards-compat. but means that an
# entity "utterance" will be overridden
intent.matches['utterance'] = utt

return intent
except Exception as e:
LOG.error(e)
Loading

0 comments on commit bcc3061

Please sign in to comment.