Skip to content

Commit

Permalink
Fix/optional adapt (#20)
Browse files Browse the repository at this point in the history
* optional adapt

authored-by: jarbasai <[email protected]>
  • Loading branch information
JarbasAl authored May 7, 2022
1 parent 86c709d commit 55f45a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 2 additions & 6 deletions ovos_workshop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
from ovos_utils.skills.settings import PrivateSettings
from ovos_utils.sound import wait_while_speaking
from ovos_workshop.skills.decorators import *

from ovos_workshop.skills.decorators.killable import killable_event, \
AbortEvent, AbortQuestion
from ovos_utils.skills.audioservice import AudioServiceInterface
from ovos_utils.events import EventContainer
from ovos_workshop.skills.layers import IntentLayers
from ovos_workshop.skills.ovos import get_non_properties
from ovos_workshop.skills.ovos import Intent, IntentBuilder, get_non_properties
from ovos_utils.gui import GUIInterface
from ovos_utils.intents.intent_service_interface import munge_regex
from ovos_utils.events import create_wrapper
Expand All @@ -40,11 +41,6 @@ def pronounce_number(n, *args, **kwargs):

def extract_number(*args, **kwargs):
return None
try:
from adapt.intent import IntentBuilder, Intent
except ImportError:
# adapt is optional, OVOSAbstractApplication might not use intents
IntentBuilder = Intent = None


class OVOSAbstractApplication:
Expand Down
13 changes: 10 additions & 3 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ovos_utils.skills.settings import PrivateSettings

ensure_mycroft_import()
from adapt.intent import Intent, IntentBuilder

from mycroft import dialog
from mycroft.skills.mycroft_skill.event_container import create_wrapper

Expand All @@ -19,6 +19,13 @@
from ovos_workshop.skills.layers import IntentLayers


try:
from adapt.intent import IntentBuilder, Intent
except ImportError:
# adapt is optional, OVOSAbstractApplication might not use intents
IntentBuilder = Intent = None


class OVOSSkill(MycroftSkill):
"""
New features:
Expand Down Expand Up @@ -70,10 +77,10 @@ def _register_decorated(self):

def register_intent_layer(self, layer_name, intent_list):
for intent_file in intent_list:
if isinstance(intent_file, IntentBuilder):
if IntentBuilder is not None and isinstance(intent_file, IntentBuilder):
intent = intent_file.build()
name = intent.name
elif isinstance(intent_file, Intent):
elif Intent is not None and isinstance(intent_file, Intent):
name = intent_file.name
else:
name = intent_file
Expand Down

0 comments on commit 55f45a9

Please sign in to comment.