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

if it quacks like a duck... #164

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 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 All @@ -1224,8 +1230,9 @@ def register_intent(self, intent_parser: Union[IntentBuilder, Intent, str],
file to parse utterance for the handler.
handler (func): function to register with intent
"""
if (isinstance(intent_parser, str) and
intent_parser.endswith('.intent')):
if isinstance(intent_parser, str):
if not intent_parser.endswith('.intent'):
raise ValueError
return self.register_intent_file(intent_parser, handler)
return self._register_adapt_intent(intent_parser, handler)

Expand Down Expand Up @@ -1413,10 +1420,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
Loading