Skip to content

Commit 6a38ce9

Browse files
committed
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)
1 parent af962d1 commit 6a38ce9

9 files changed

+606
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the 'License'). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
from __future__ import absolute_import
16+
17+
from .can_fulfill_intent import CanFulfillIntent
18+
from .can_fulfill_intent_request import CanFulfillIntentRequest
19+
from .can_fulfill_intent_values import CanFulfillIntentValues
20+
from .can_fulfill_slot import CanFulfillSlot
21+
from .can_fulfill_slot_values import CanFulfillSlotValues
22+
from .can_understand_slot_values import CanUnderstandSlotValues
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional
25+
from datetime import datetime
26+
from ask_sdk_model.canfulfill.can_fulfill_intent_values import CanFulfillIntentValues
27+
from ask_sdk_model.canfulfill.can_fulfill_slot import CanFulfillSlot
28+
29+
30+
class CanFulfillIntent(object):
31+
"""
32+
CanFulfillIntent represents the response to canFulfillIntentRequest includes the details about whether the skill can understand and fulfill the intent request with detected slots.
33+
34+
35+
:param can_fulfill:
36+
:type can_fulfill: (optional) ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues
37+
: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.
38+
:type slots: (optional) dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot)
39+
40+
"""
41+
deserialized_types = {
42+
'can_fulfill': 'ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues',
43+
'slots': 'dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot)'
44+
}
45+
46+
attribute_map = {
47+
'can_fulfill': 'canFulfill',
48+
'slots': 'slots'
49+
}
50+
51+
def __init__(self, can_fulfill=None, slots=None):
52+
# type: (Optional[CanFulfillIntentValues], Optional[Dict[str, CanFulfillSlot]]) -> None
53+
"""CanFulfillIntent represents the response to canFulfillIntentRequest includes the details about whether the skill can understand and fulfill the intent request with detected slots.
54+
55+
:param can_fulfill:
56+
:type can_fulfill: (optional) ask_sdk_model.canfulfill.can_fulfill_intent_values.CanFulfillIntentValues
57+
: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.
58+
:type slots: (optional) dict(str, ask_sdk_model.canfulfill.can_fulfill_slot.CanFulfillSlot)
59+
"""
60+
self.__discriminator_value = None
61+
62+
self.can_fulfill = can_fulfill
63+
self.slots = slots
64+
65+
def to_dict(self):
66+
# type: () -> Dict[str, object]
67+
"""Returns the model properties as a dict"""
68+
result = {}
69+
70+
for attr, _ in six.iteritems(self.deserialized_types):
71+
value = getattr(self, attr)
72+
if isinstance(value, list):
73+
result[attr] = list(map(
74+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
75+
x.value if isinstance(x, Enum) else x,
76+
value
77+
))
78+
elif isinstance(value, Enum):
79+
result[attr] = value.value
80+
elif hasattr(value, "to_dict"):
81+
result[attr] = value.to_dict()
82+
elif isinstance(value, dict):
83+
result[attr] = dict(map(
84+
lambda item: (item[0], item[1].to_dict())
85+
if hasattr(item[1], "to_dict") else
86+
(item[0], item[1].value)
87+
if isinstance(item[1], Enum) else item,
88+
value.items()
89+
))
90+
else:
91+
result[attr] = value
92+
93+
return result
94+
95+
def to_str(self):
96+
# type: () -> str
97+
"""Returns the string representation of the model"""
98+
return pprint.pformat(self.to_dict())
99+
100+
def __repr__(self):
101+
# type: () -> str
102+
"""For `print` and `pprint`"""
103+
return self.to_str()
104+
105+
def __eq__(self, other):
106+
# type: (object) -> bool
107+
"""Returns true if both objects are equal"""
108+
if not isinstance(other, CanFulfillIntent):
109+
return False
110+
111+
return self.__dict__ == other.__dict__
112+
113+
def __ne__(self, other):
114+
# type: (object) -> bool
115+
"""Returns true if both objects are not equal"""
116+
return not self == other
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
from ask_sdk_model.request import Request
22+
23+
24+
if typing.TYPE_CHECKING:
25+
from typing import Dict, List, Optional
26+
from datetime import datetime
27+
from ask_sdk_model.dialog_state import DialogState
28+
from ask_sdk_model.intent import Intent
29+
30+
31+
class CanFulfillIntentRequest(Request):
32+
"""
33+
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.
34+
35+
36+
:param request_id: Represents the unique identifier for the specific request.
37+
:type request_id: (optional) str
38+
: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.
39+
:type timestamp: (optional) datetime
40+
:param dialog_state:
41+
:type dialog_state: (optional) ask_sdk_model.dialog_state.DialogState
42+
:param intent:
43+
:type intent: (optional) ask_sdk_model.intent.Intent
44+
:param locale: A string indicating the user’s locale. For example: en-US.
45+
:type locale: (optional) str
46+
47+
"""
48+
deserialized_types = {
49+
'object_type': 'str',
50+
'request_id': 'str',
51+
'timestamp': 'datetime',
52+
'dialog_state': 'ask_sdk_model.dialog_state.DialogState',
53+
'intent': 'ask_sdk_model.intent.Intent',
54+
'locale': 'str'
55+
}
56+
57+
attribute_map = {
58+
'object_type': 'type',
59+
'request_id': 'requestId',
60+
'timestamp': 'timestamp',
61+
'dialog_state': 'dialogState',
62+
'intent': 'intent',
63+
'locale': 'locale'
64+
}
65+
66+
def __init__(self, request_id=None, timestamp=None, dialog_state=None, intent=None, locale=None):
67+
# type: (Optional[str], Optional[datetime], Optional[DialogState], Optional[Intent], Optional[str]) -> None
68+
"""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.
69+
70+
:param request_id: Represents the unique identifier for the specific request.
71+
:type request_id: (optional) str
72+
: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.
73+
:type timestamp: (optional) datetime
74+
:param dialog_state:
75+
:type dialog_state: (optional) ask_sdk_model.dialog_state.DialogState
76+
:param intent:
77+
:type intent: (optional) ask_sdk_model.intent.Intent
78+
:param locale: A string indicating the user’s locale. For example: en-US.
79+
:type locale: (optional) str
80+
"""
81+
self.__discriminator_value = "CanFulfillIntentRequest"
82+
83+
self.object_type = self.__discriminator_value
84+
super(CanFulfillIntentRequest, self).__init__(object_type=self.__discriminator_value, request_id=request_id, timestamp=timestamp)
85+
self.dialog_state = dialog_state
86+
self.intent = intent
87+
self.locale = locale
88+
89+
def to_dict(self):
90+
# type: () -> Dict[str, object]
91+
"""Returns the model properties as a dict"""
92+
result = {}
93+
94+
for attr, _ in six.iteritems(self.deserialized_types):
95+
value = getattr(self, attr)
96+
if isinstance(value, list):
97+
result[attr] = list(map(
98+
lambda x: x.to_dict() if hasattr(x, "to_dict") else
99+
x.value if isinstance(x, Enum) else x,
100+
value
101+
))
102+
elif isinstance(value, Enum):
103+
result[attr] = value.value
104+
elif hasattr(value, "to_dict"):
105+
result[attr] = value.to_dict()
106+
elif isinstance(value, dict):
107+
result[attr] = dict(map(
108+
lambda item: (item[0], item[1].to_dict())
109+
if hasattr(item[1], "to_dict") else
110+
(item[0], item[1].value)
111+
if isinstance(item[1], Enum) else item,
112+
value.items()
113+
))
114+
else:
115+
result[attr] = value
116+
117+
return result
118+
119+
def to_str(self):
120+
# type: () -> str
121+
"""Returns the string representation of the model"""
122+
return pprint.pformat(self.to_dict())
123+
124+
def __repr__(self):
125+
# type: () -> str
126+
"""For `print` and `pprint`"""
127+
return self.to_str()
128+
129+
def __eq__(self, other):
130+
# type: (object) -> bool
131+
"""Returns true if both objects are equal"""
132+
if not isinstance(other, CanFulfillIntentRequest):
133+
return False
134+
135+
return self.__dict__ == other.__dict__
136+
137+
def __ne__(self, other):
138+
# type: (object) -> bool
139+
"""Returns true if both objects are not equal"""
140+
return not self == other
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# coding: utf-8
2+
3+
#
4+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7+
# except in compliance with the License. A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
13+
# the specific language governing permissions and limitations under the License.
14+
#
15+
16+
import pprint
17+
import re # noqa: F401
18+
import six
19+
import typing
20+
from enum import Enum
21+
22+
23+
if typing.TYPE_CHECKING:
24+
from typing import Dict, List, Optional
25+
from datetime import datetime
26+
27+
28+
class CanFulfillIntentValues(Enum):
29+
"""
30+
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.
31+
32+
33+
34+
Allowed enum values: [YES, NO, MAYBE]
35+
"""
36+
YES = "YES"
37+
NO = "NO"
38+
MAYBE = "MAYBE"
39+
def to_dict(self):
40+
# type: () -> Dict[str, object]
41+
"""Returns the model properties as a dict"""
42+
result = {self.name: self.value}
43+
return result
44+
45+
def to_str(self):
46+
# type: () -> str
47+
"""Returns the string representation of the model"""
48+
return pprint.pformat(self.value)
49+
50+
def __repr__(self):
51+
# type: () -> str
52+
"""For `print` and `pprint`"""
53+
return self.to_str()
54+
55+
def __eq__(self, other):
56+
# type: (object) -> bool
57+
"""Returns true if both objects are equal"""
58+
if not isinstance(other, CanFulfillIntentValues):
59+
return False
60+
61+
return self.__dict__ == other.__dict__
62+
63+
def __ne__(self, other):
64+
# type: (object) -> bool
65+
"""Returns true if both objects are not equal"""
66+
return not self == other

0 commit comments

Comments
 (0)