Skip to content

Commit

Permalink
if it quacks like a duck...
Browse files Browse the repository at this point in the history
isinstancechecks prove to be too restrictive
  • Loading branch information
JarbasAl committed Dec 29, 2023
1 parent d93b5bf commit b2aff34
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ovos_workshop/skills/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,13 +1205,19 @@ def register_intent_layer(self, layer_name: str,
@param intent_list: List of intents associated with the intent layer
"""
for intent_file in intent_list:
if IntentBuilder is not None and isinstance(intent_file, IntentBuilder):
intent = intent_file.build()
name = intent.name
elif Intent is not None and isinstance(intent_file, Intent):
name = intent_file.name
else:
if isinstance(intent_file, str):
name = f'{self.skill_id}:{intent_file}'
else:
if hasattr(intent_file, "build"):
try:
intent_file = intent_file.build()
except:
pass
try:
name = intent_file.name
except:
name = f'{self.skill_id}:{intent_file}'

self.intent_layers.update_layer(layer_name, [name])

def register_intent(self, intent_parser: Union[IntentBuilder, Intent, str],
Expand Down Expand Up @@ -1413,10 +1419,11 @@ def _register_adapt_intent(self,
intent_parser: Intent object to parse utterance for the handler.
handler (func): function to register with intent
"""
if isinstance(intent_parser, IntentBuilder):
intent_parser = intent_parser.build()
elif not isinstance(intent_parser, Intent):
raise ValueError('"' + str(intent_parser) + '" is not an Intent')
if hasattr(intent_parser, "build"):
try:
intent_parser = intent_parser.build()
except:
pass

# Default to the handler's function name if none given
is_anonymous = not intent_parser.name
Expand Down

0 comments on commit b2aff34

Please sign in to comment.