-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This release includes the following:
- Models for [CanFulfillIntentRequest, for Name-free Interactions](https://developer.amazon.com/docs/custom-skills/implement-canfulfillintentrequest-for-name-free-interaction.html)
- Loading branch information
Showing
9 changed files
with
606 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# coding: utf-8 | ||
|
||
# | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
# the specific language governing permissions and limitations under the License. | ||
# | ||
from __future__ import absolute_import | ||
|
||
from .can_fulfill_intent import CanFulfillIntent | ||
from .can_fulfill_intent_request import CanFulfillIntentRequest | ||
from .can_fulfill_intent_values import CanFulfillIntentValues | ||
from .can_fulfill_slot import CanFulfillSlot | ||
from .can_fulfill_slot_values import CanFulfillSlotValues | ||
from .can_understand_slot_values import CanUnderstandSlotValues |
116 changes: 116 additions & 0 deletions
116
ask-sdk-model/ask_sdk_model/canfulfill/can_fulfill_intent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# coding: utf-8 | ||
|
||
# | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
# the specific language governing permissions and limitations under the License. | ||
# | ||
|
||
import pprint | ||
import re # noqa: F401 | ||
import six | ||
import typing | ||
from enum import Enum | ||
|
||
|
||
if typing.TYPE_CHECKING: | ||
from typing import Dict, List, Optional | ||
from datetime import datetime | ||
from ask_sdk_model.canfulfill.can_fulfill_intent_values import CanFulfillIntentValues | ||
from ask_sdk_model.canfulfill.can_fulfill_slot import CanFulfillSlot | ||
|
||
|
||
class CanFulfillIntent(object): | ||
""" | ||
CanFulfillIntent represents the response to canFulfillIntentRequest includes the details about whether the skill can understand and fulfill the intent request with detected slots. | ||
:param can_fulfill: | ||
:type can_fulfill: (optional) ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues | ||
:param slots: A map that represents skill's detailed response to each detected slot within the intent such as if skill can understand and fulfill the detected slot. This supplements the overall canFulfillIntent response and help Alexa make better ranking and arbitration decisions. The key is the name of the slot. The value is an object of type CanFulfillSlot. | ||
:type slots: (optional) dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot) | ||
""" | ||
deserialized_types = { | ||
'can_fulfill': 'ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues', | ||
'slots': 'dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot)' | ||
} | ||
|
||
attribute_map = { | ||
'can_fulfill': 'canFulfill', | ||
'slots': 'slots' | ||
} | ||
|
||
def __init__(self, can_fulfill=None, slots=None): | ||
# type: (Optional[CanFulfillIntentValues], Optional[Dict[str, CanFulfillSlot]]) -> None | ||
"""CanFulfillIntent represents the response to canFulfillIntentRequest includes the details about whether the skill can understand and fulfill the intent request with detected slots. | ||
:param can_fulfill: | ||
:type can_fulfill: (optional) ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues | ||
:param slots: A map that represents skill's detailed response to each detected slot within the intent such as if skill can understand and fulfill the detected slot. This supplements the overall canFulfillIntent response and help Alexa make better ranking and arbitration decisions. The key is the name of the slot. The value is an object of type CanFulfillSlot. | ||
:type slots: (optional) dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot) | ||
""" | ||
self.__discriminator_value = None | ||
|
||
self.can_fulfill = can_fulfill | ||
self.slots = slots | ||
|
||
def to_dict(self): | ||
# type: () -> Dict[str, object] | ||
"""Returns the model properties as a dict""" | ||
result = {} | ||
|
||
for attr, _ in six.iteritems(self.deserialized_types): | ||
value = getattr(self, attr) | ||
if isinstance(value, list): | ||
result[attr] = list(map( | ||
lambda x: x.to_dict() if hasattr(x, "to_dict") else | ||
x.value if isinstance(x, Enum) else x, | ||
value | ||
)) | ||
elif isinstance(value, Enum): | ||
result[attr] = value.value | ||
elif hasattr(value, "to_dict"): | ||
result[attr] = value.to_dict() | ||
elif isinstance(value, dict): | ||
result[attr] = dict(map( | ||
lambda item: (item[0], item[1].to_dict()) | ||
if hasattr(item[1], "to_dict") else | ||
(item[0], item[1].value) | ||
if isinstance(item[1], Enum) else item, | ||
value.items() | ||
)) | ||
else: | ||
result[attr] = value | ||
|
||
return result | ||
|
||
def to_str(self): | ||
# type: () -> str | ||
"""Returns the string representation of the model""" | ||
return pprint.pformat(self.to_dict()) | ||
|
||
def __repr__(self): | ||
# type: () -> str | ||
"""For `print` and `pprint`""" | ||
return self.to_str() | ||
|
||
def __eq__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are equal""" | ||
if not isinstance(other, CanFulfillIntent): | ||
return False | ||
|
||
return self.__dict__ == other.__dict__ | ||
|
||
def __ne__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are not equal""" | ||
return not self == other |
140 changes: 140 additions & 0 deletions
140
ask-sdk-model/ask_sdk_model/canfulfill/can_fulfill_intent_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
# coding: utf-8 | ||
|
||
# | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
# the specific language governing permissions and limitations under the License. | ||
# | ||
|
||
import pprint | ||
import re # noqa: F401 | ||
import six | ||
import typing | ||
from enum import Enum | ||
from ask_sdk_model.request import Request | ||
|
||
|
||
if typing.TYPE_CHECKING: | ||
from typing import Dict, List, Optional | ||
from datetime import datetime | ||
from ask_sdk_model.dialog_state import DialogState | ||
from ask_sdk_model.intent import Intent | ||
|
||
|
||
class CanFulfillIntentRequest(Request): | ||
""" | ||
An object that represents a request made to skill to query whether the skill can understand and fulfill the intent request with detected slots, before actually asking the skill to take action. Skill should be aware this is not to actually take action, skill should handle this request without causing side-effect, skill should not modify some state outside its scope or has an observable interaction with its calling functions or the outside world besides returning a value, such as playing sound,turning on/off lights, committing a transaction or a charge. | ||
:param request_id: Represents the unique identifier for the specific request. | ||
:type request_id: (optional) str | ||
:param timestamp: Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service. | ||
:type timestamp: (optional) datetime | ||
:param dialog_state: | ||
:type dialog_state: (optional) ask_sdk_model.dialog_state.DialogState | ||
:param intent: | ||
:type intent: (optional) ask_sdk_model.intent.Intent | ||
:param locale: A string indicating the user’s locale. For example: en-US. | ||
:type locale: (optional) str | ||
""" | ||
deserialized_types = { | ||
'object_type': 'str', | ||
'request_id': 'str', | ||
'timestamp': 'datetime', | ||
'dialog_state': 'ask_sdk_model.dialog_state.DialogState', | ||
'intent': 'ask_sdk_model.intent.Intent', | ||
'locale': 'str' | ||
} | ||
|
||
attribute_map = { | ||
'object_type': 'type', | ||
'request_id': 'requestId', | ||
'timestamp': 'timestamp', | ||
'dialog_state': 'dialogState', | ||
'intent': 'intent', | ||
'locale': 'locale' | ||
} | ||
|
||
def __init__(self, request_id=None, timestamp=None, dialog_state=None, intent=None, locale=None): | ||
# type: (Optional[str], Optional[datetime], Optional[DialogState], Optional[Intent], Optional[str]) -> None | ||
"""An object that represents a request made to skill to query whether the skill can understand and fulfill the intent request with detected slots, before actually asking the skill to take action. Skill should be aware this is not to actually take action, skill should handle this request without causing side-effect, skill should not modify some state outside its scope or has an observable interaction with its calling functions or the outside world besides returning a value, such as playing sound,turning on/off lights, committing a transaction or a charge. | ||
:param request_id: Represents the unique identifier for the specific request. | ||
:type request_id: (optional) str | ||
:param timestamp: Provides the date and time when Alexa sent the request as an ISO 8601 formatted string. Used to verify the request when hosting your skill as a web service. | ||
:type timestamp: (optional) datetime | ||
:param dialog_state: | ||
:type dialog_state: (optional) ask_sdk_model.dialog_state.DialogState | ||
:param intent: | ||
:type intent: (optional) ask_sdk_model.intent.Intent | ||
:param locale: A string indicating the user’s locale. For example: en-US. | ||
:type locale: (optional) str | ||
""" | ||
self.__discriminator_value = "CanFulfillIntentRequest" | ||
|
||
self.object_type = self.__discriminator_value | ||
super(CanFulfillIntentRequest, self).__init__(object_type=self.__discriminator_value, request_id=request_id, timestamp=timestamp) | ||
self.dialog_state = dialog_state | ||
self.intent = intent | ||
self.locale = locale | ||
|
||
def to_dict(self): | ||
# type: () -> Dict[str, object] | ||
"""Returns the model properties as a dict""" | ||
result = {} | ||
|
||
for attr, _ in six.iteritems(self.deserialized_types): | ||
value = getattr(self, attr) | ||
if isinstance(value, list): | ||
result[attr] = list(map( | ||
lambda x: x.to_dict() if hasattr(x, "to_dict") else | ||
x.value if isinstance(x, Enum) else x, | ||
value | ||
)) | ||
elif isinstance(value, Enum): | ||
result[attr] = value.value | ||
elif hasattr(value, "to_dict"): | ||
result[attr] = value.to_dict() | ||
elif isinstance(value, dict): | ||
result[attr] = dict(map( | ||
lambda item: (item[0], item[1].to_dict()) | ||
if hasattr(item[1], "to_dict") else | ||
(item[0], item[1].value) | ||
if isinstance(item[1], Enum) else item, | ||
value.items() | ||
)) | ||
else: | ||
result[attr] = value | ||
|
||
return result | ||
|
||
def to_str(self): | ||
# type: () -> str | ||
"""Returns the string representation of the model""" | ||
return pprint.pformat(self.to_dict()) | ||
|
||
def __repr__(self): | ||
# type: () -> str | ||
"""For `print` and `pprint`""" | ||
return self.to_str() | ||
|
||
def __eq__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are equal""" | ||
if not isinstance(other, CanFulfillIntentRequest): | ||
return False | ||
|
||
return self.__dict__ == other.__dict__ | ||
|
||
def __ne__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are not equal""" | ||
return not self == other |
66 changes: 66 additions & 0 deletions
66
ask-sdk-model/ask_sdk_model/canfulfill/can_fulfill_intent_values.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# coding: utf-8 | ||
|
||
# | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | ||
# the specific language governing permissions and limitations under the License. | ||
# | ||
|
||
import pprint | ||
import re # noqa: F401 | ||
import six | ||
import typing | ||
from enum import Enum | ||
|
||
|
||
if typing.TYPE_CHECKING: | ||
from typing import Dict, List, Optional | ||
from datetime import datetime | ||
|
||
|
||
class CanFulfillIntentValues(Enum): | ||
""" | ||
Overall if skill can understand and fulfill the intent with detected slots. Respond YES when skill understands all slots, can fulfill all slots, and can fulfill the request in its entirety. Respond NO when skill either cannot understand the intent, cannot understand all the slots, or cannot fulfill all the slots. Respond MAYBE when skill can understand the intent, can partially or fully understand the slots, and can partially or fully fulfill the slots. The only cases where should respond MAYBE is when skill partially understand the request and can potentially complete the request if skill get more data, either through callbacks or through a multi-turn conversation with the user. | ||
Allowed enum values: [YES, NO, MAYBE] | ||
""" | ||
YES = "YES" | ||
NO = "NO" | ||
MAYBE = "MAYBE" | ||
def to_dict(self): | ||
# type: () -> Dict[str, object] | ||
"""Returns the model properties as a dict""" | ||
result = {self.name: self.value} | ||
return result | ||
|
||
def to_str(self): | ||
# type: () -> str | ||
"""Returns the string representation of the model""" | ||
return pprint.pformat(self.value) | ||
|
||
def __repr__(self): | ||
# type: () -> str | ||
"""For `print` and `pprint`""" | ||
return self.to_str() | ||
|
||
def __eq__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are equal""" | ||
if not isinstance(other, CanFulfillIntentValues): | ||
return False | ||
|
||
return self.__dict__ == other.__dict__ | ||
|
||
def __ne__(self, other): | ||
# type: (object) -> bool | ||
"""Returns true if both objects are not equal""" | ||
return not self == other |
Oops, something went wrong.