Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:intents #7

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
Returns:
IntentMatch if handled otherwise None.
"""
if self.active_persona and self.voc_match(utterances[0], "Release", lang):
return IntentHandlerMatch(match_type='persona:release',
match_data={"persona": self.active_persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])

match = self.intent_matchers[lang].calc_intent(utterances[0].lower())

if match["name"]:
LOG.info(f"Persona exact match: {match}")
LOG.info(f"Persona intent exact match: {match}")
persona = match["entities"].pop("persona")
if match["name"] == "summon":
return IntentHandlerMatch(match_type='persona:summon',
Expand All @@ -180,11 +186,18 @@ def match_high(self, utterances: List[str], lang: Optional[str] = None,
skill_id="persona.openvoiceos",
utterance=utterances[0])

if self.active_persona and self.voc_match(utterances[0], "Release", lang):
return IntentHandlerMatch(match_type='persona:release',
match_data={"persona": self.active_persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])
# override regular intent parsing, handle utterance until persona release
if self.active_persona:
LOG.debug(f"Persona is active: {self.active_persona}")
ans = self.chatbox_ask(utterances[0],
lang=lang,
persona=self.active_persona)
if ans:
return IntentHandlerMatch(match_type='persona:answer',
match_data={"answer": ans,
"persona": self.active_persona},
skill_id="persona.openvoiceos",
utterance=utterances[0])

def match_medium(self, utterances: List[str], lang: str, message: Message) -> None:
return self.match_high(utterances, lang, message)
Expand Down Expand Up @@ -219,8 +232,10 @@ def handle_persona_summon(self, message):
self.speak_dialog("unknown_persona")
else:
self.active_persona = persona
LOG.info(f"Summoned Persona: {self.active_persona}")

def handle_persona_release(self, message):
LOG.info(f"Releasing Persona: {self.active_persona}")
self.active_persona = None


Expand Down
Loading