Skip to content

Commit

Permalink
lazy manage history
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Jun 15, 2022
1 parent 9e26129 commit 26c66e2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mycroft/skills/intent_services/converse_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ def activate_skill(self, skill_id):
self.deactivate_skill(skill_id)
# add skill with timestamp to start of active list
self.active_skills.insert(0, [skill_id, time.time()])
self._prune_history()

def deactivate_skill(self, skill_id):
active_ids = [s[0] for s in self.active_skills]
if skill_id in active_ids:
idx = active_ids.index(skill_id)
self.active_skills.pop(idx)
self._prune_history()

def is_active(self, skill_id):
self._prune_history()
active_ids = [s[0] for s in self.active_skills]
return skill_id in active_ids

Expand All @@ -49,6 +52,7 @@ def clear(self):
self.history = [] # [Message , timestamp]

def as_dict(self):
self._prune_history()
return {
"active_skills": self.active_skills,
"session_id": self.session_id,
Expand Down

0 comments on commit 26c66e2

Please sign in to comment.