Skip to content

Commit

Permalink
feat/active skills from Session
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Sep 20, 2023
1 parent b404af7 commit 86d2d52
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions ovos_core/intent_services/converse_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def deactivate_skill(self, skill_id, source_skill=None, message=None):
if message:
session.update_history(message)
session.deactivate_skill(skill_id)
# also update default session
if session.session_id != SessionManager.default_session.session_id:
SessionManager.default_session.deactivate_skill(skill_id)

# keep message.context
message = message or Message("")
message.context["skill_id"] = self.skill_id
# send bus event
self.bus.emit(
Message("intent.service.skills.deactivated",
data={"skill_id": skill_id},
context={"skill_id": skill_id}))
message.forward("intent.service.skills.deactivated",
data={"skill_id": skill_id}))
if skill_id in self._consecutive_activations:
self._consecutive_activations[skill_id] = 0

Expand All @@ -86,18 +86,14 @@ def activate_skill(self, skill_id, source_skill=None, message=None):
if message:
session.update_history(message)
session.activate_skill(skill_id)
# also update default session
if session.session_id != SessionManager.default_session.session_id:
SessionManager.default_session.activate_skill(skill_id)

if message:
msg = message.forward("intent.service.skills.activated",
# keep message.context
message = message or Message("")
message.context["skill_id"] = self.skill_id
message = message.forward("intent.service.skills.activated",
{"skill_id": skill_id})
else:
msg = Message("intent.service.skills.activated",
{"skill_id": skill_id})
# send bus event
self.bus.emit(msg)
self.bus.emit(message)
# update activation counter
self._consecutive_activations[skill_id] += 1

Expand Down

0 comments on commit 86d2d52

Please sign in to comment.