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

fix/deactivate inside intent/converse #451

Merged
merged 15 commits into from
May 4, 2024
Merged

fix/deactivate inside intent/converse #451

merged 15 commits into from
May 4, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented May 2, 2024

closes #450

needs OpenVoiceOS/OVOS-workshop#198

CAVEATS:

  • self.deactivate() can now be called inside intent handlers
  • self.deactivate() can now be called inside converse handlers, but ONLY if they return False
  • self.deactivate() can now be called inside fallback handlers, but ONLY if they return False

if converse/fallback returns True (to consume the utterance) the skill is reactivated right after the handler

if you need to deactivate a skill and also consume the utterance, then you need to use the callback instead

class MySkill(OVOSSkill):
    def converse(self, message):  # or fallback skill handler
        self.do_deactivation = True
        return True

    def handle_activate(self, message: Message):
		"""called after converse return True (but not False)"""
        if self.do_deactivation:
			self.deactivate()
       	self.do_deactivation = False

solving this limitation will require deeper changes in ovos-workshop and is not a trivial fix, a test case is included with a TODO

expected_messages = [
    "recognizer_loop:utterance", # converse gets it
    f"{self.skill_id}.converse.ping",
    "skill.converse.pong",
    f"{self.skill_id}.converse.request",
    # converse code
    "intent.service.skills.deactivate",
    "intent.service.skills.deactivated",
    f"{self.skill_id}.deactivate",
    "ovos.session.update_default",
    ###########
    # TODO - activate is called here if converse return True
    "intent.service.skills.activate",
    "intent.service.skills.activated",
    f"{self.skill_id}.activate",
    "ovos.session.update_default",
    # /TODO - ovos-workshop PR needed
    ###########
    "skill.converse.response",  # conversed!
    # session updated
    "ovos.session.update_default"
]

@JarbasAl JarbasAl added the bug Something isn't working label May 2, 2024
@JarbasAl JarbasAl changed the title fix/450 fix/deactivate inside intent/converse May 3, 2024
@JarbasAl JarbasAl marked this pull request as ready for review May 4, 2024 06:00
Copy link

codecov bot commented May 4, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 66.70%. Comparing base (b68a70d) to head (a6e3826).
Report is 1 commits behind head on dev.

Files Patch % Lines
ovos_core/intent_services/ocp_service.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #451      +/-   ##
==========================================
- Coverage   66.70%   66.70%   -0.01%     
==========================================
  Files          15       15              
  Lines        2607     2610       +3     
==========================================
+ Hits         1739     1741       +2     
- Misses        868      869       +1     
Flag Coverage Δ
unittests 66.70% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JarbasAl JarbasAl requested a review from a team May 4, 2024 06:09
@JarbasAl JarbasAl merged commit b428104 into dev May 4, 2024
9 checks passed
@JarbasAl JarbasAl deleted the fix/450 branch May 4, 2024 21:09
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request May 4, 2024
JarbasAl added a commit that referenced this pull request May 4, 2024
avoid the caveats documented in #451

companion to OpenVoiceOS/OVOS-workshop#199
JarbasAl added a commit to OpenVoiceOS/OVOS-workshop that referenced this pull request May 4, 2024
JarbasAl added a commit that referenced this pull request May 4, 2024
* fix/deactivate_in_converse/fallback

avoid the caveats documented in #451

companion to OpenVoiceOS/OVOS-workshop#199

* improve tests to account for message order

* tests
@JarbasAl JarbasAl added this to the 0.0.8 milestone May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug - can not deactivate a skill inside an intent/converse
1 participant