aws-lex-conversation 2.1.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +28 -6
- data/lib/aws/lex/conversation.rb +38 -1
- data/lib/aws/lex/conversation/base.rb +13 -10
- data/lib/aws/lex/conversation/handler/delegate.rb +1 -3
- data/lib/aws/lex/conversation/handler/echo.rb +6 -4
- data/lib/aws/lex/conversation/response/base.rb +11 -10
- data/lib/aws/lex/conversation/response/close.rb +5 -11
- data/lib/aws/lex/conversation/response/confirm_intent.rb +4 -13
- data/lib/aws/lex/conversation/response/delegate.rb +4 -11
- data/lib/aws/lex/conversation/response/elicit_intent.rb +4 -7
- data/lib/aws/lex/conversation/response/elicit_slot.rb +5 -12
- data/lib/aws/lex/conversation/slot/elicitation.rb +6 -4
- data/lib/aws/lex/conversation/support/mixins/responses.rb +14 -20
- data/lib/aws/lex/conversation/type/base.rb +10 -4
- data/lib/aws/lex/conversation/type/bot.rb +3 -1
- data/lib/aws/lex/conversation/type/checkpoint.rb +57 -0
- data/lib/aws/lex/conversation/type/{confirmation_status.rb → confirmation_state.rb} +1 -1
- data/lib/aws/lex/conversation/type/context.rb +4 -4
- data/lib/aws/lex/conversation/type/{slot_detail.rb → dialog_action.rb} +4 -4
- data/lib/aws/lex/conversation/type/dialog_action_type.rb +3 -3
- data/lib/aws/lex/conversation/type/event.rb +25 -18
- data/lib/aws/lex/conversation/type/{output_dialog_mode.rb → input_mode.rb} +3 -2
- data/lib/aws/lex/conversation/type/intent.rb +20 -23
- data/lib/aws/lex/conversation/type/intent_confidence.rb +5 -5
- data/lib/aws/lex/conversation/type/interpretation.rb +23 -0
- data/lib/aws/lex/conversation/type/message.rb +4 -2
- data/lib/aws/lex/conversation/type/message/content_type.rb +2 -1
- data/lib/aws/lex/conversation/type/response.rb +3 -4
- data/lib/aws/lex/conversation/type/response_card.rb +5 -6
- data/lib/aws/lex/conversation/type/{sentiment_label.rb → sentiment.rb} +1 -1
- data/lib/aws/lex/conversation/type/sentiment_response.rb +3 -3
- data/lib/aws/lex/conversation/type/sentiment_score.rb +10 -20
- data/lib/aws/lex/conversation/type/session_attributes.rb +29 -0
- data/lib/aws/lex/conversation/type/session_state.rb +25 -0
- data/lib/aws/lex/conversation/type/slot.rb +63 -20
- data/lib/aws/lex/conversation/type/{slot_resolution.rb → slot_shape.rb} +4 -3
- data/lib/aws/lex/conversation/type/slot_value.rb +40 -0
- data/lib/aws/lex/conversation/version.rb +1 -1
- metadata +13 -11
- data/lib/aws/lex/conversation/type/recent_intent_summary_view.rb +0 -29
- data/lib/aws/lex/conversation/type/response_card/content_type.rb +0 -17
- data/lib/aws/lex/conversation/type/response_card/generic_attachment.rb +0 -26
@@ -7,27 +7,17 @@ module Aws
|
|
7
7
|
class SentimentScore
|
8
8
|
include Base
|
9
9
|
|
10
|
-
required :
|
11
|
-
required :negative
|
12
|
-
required :neutral
|
13
|
-
required :
|
10
|
+
required :mixed
|
11
|
+
required :negative
|
12
|
+
required :neutral
|
13
|
+
required :positive
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
params = parts.each_with_object({}) do |part, hash|
|
23
|
-
label = part.first
|
24
|
-
value = part.last.to_f
|
25
|
-
hash[label] = value
|
26
|
-
end
|
27
|
-
|
28
|
-
shrink_wrap(params)
|
29
|
-
end
|
30
|
-
end
|
15
|
+
coerce(
|
16
|
+
mixed: float!(nilable: true),
|
17
|
+
negative: float!(nilable: true),
|
18
|
+
neutral: float!(nilable: true),
|
19
|
+
positive: float!(nilable: true)
|
20
|
+
)
|
31
21
|
end
|
32
22
|
end
|
33
23
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Lex
|
5
|
+
class Conversation
|
6
|
+
module Type
|
7
|
+
class SessionAttributes < Hash
|
8
|
+
include Base
|
9
|
+
|
10
|
+
optional :checkpoints
|
11
|
+
|
12
|
+
def checkpoints
|
13
|
+
@checkpoints ||= JSON.parse(
|
14
|
+
Base64.urlsafe_decode64(fetch(:checkpoints) { Base64.urlsafe_encode64([].to_json, padding: false) })
|
15
|
+
).map do |checkpoint|
|
16
|
+
Checkpoint.shrink_wrap(checkpoint)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_lex
|
21
|
+
merge(
|
22
|
+
checkpoints: Base64.urlsafe_encode64(checkpoints.map(&:to_lex).to_json, padding: false)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Lex
|
5
|
+
class Conversation
|
6
|
+
module Type
|
7
|
+
class SessionState
|
8
|
+
include Base
|
9
|
+
|
10
|
+
optional :active_contexts, default: -> { [] }
|
11
|
+
optional :dialog_action
|
12
|
+
required :intent, default: -> { {} }
|
13
|
+
required :session_attributes, default: -> { {} }
|
14
|
+
|
15
|
+
coerce(
|
16
|
+
active_contexts: Array[Context],
|
17
|
+
dialog_action: DialogAction,
|
18
|
+
intent: Intent,
|
19
|
+
session_attributes: ->(v) { SessionAttributes[v.transform_keys(&:to_sym)] }
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -7,42 +7,85 @@ module Aws
|
|
7
7
|
class Slot
|
8
8
|
include Base
|
9
9
|
|
10
|
-
required :
|
11
|
-
|
12
|
-
required :value
|
10
|
+
required :shape, default: -> { 'Scalar' }
|
11
|
+
optional :name, virtual: true
|
12
|
+
required :lex_value, from: :value, default: -> { {} }, virtual: true
|
13
|
+
required :lex_values, from: :values, default: -> { [] }, virtual: true
|
14
|
+
required :active, default: -> { false }, virtual: true
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
coerce(
|
17
|
+
shape: SlotShape,
|
18
|
+
lex_value: SlotValue,
|
19
|
+
lex_values: Array[Slot]
|
20
|
+
)
|
17
21
|
|
18
22
|
def to_lex
|
19
|
-
|
23
|
+
super.merge(
|
24
|
+
value: transform_to_lex(lex_value),
|
25
|
+
values: transform_to_lex(lex_values)
|
26
|
+
)
|
20
27
|
end
|
21
28
|
|
22
|
-
def
|
23
|
-
|
29
|
+
def value=(val)
|
30
|
+
raise TypeError, 'use values= for List-type slots' if shape.list?
|
31
|
+
|
32
|
+
lex_value.interpreted_value = val
|
24
33
|
end
|
25
34
|
|
26
|
-
def
|
27
|
-
|
35
|
+
def value
|
36
|
+
raise TypeError, 'use values for List-type slots' if shape.list?
|
37
|
+
|
38
|
+
lex_value.interpreted_value
|
28
39
|
end
|
29
40
|
|
30
|
-
|
31
|
-
|
41
|
+
# takes an array of slot values
|
42
|
+
def values=(vals)
|
43
|
+
raise TypeError, 'use value= for Scalar-type slots' if shape.scalar?
|
44
|
+
|
45
|
+
self.lex_values = vals.map do |val|
|
46
|
+
Slot.shrink_wrap(
|
47
|
+
active: true,
|
48
|
+
value: {
|
49
|
+
interpretedValue: val,
|
50
|
+
originalValue: val,
|
51
|
+
resolvedValues: [val]
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
32
55
|
end
|
33
56
|
|
34
|
-
def
|
35
|
-
|
57
|
+
def values
|
58
|
+
raise TypeError, 'use value for Scalar-type slots' if shape.scalar?
|
59
|
+
|
60
|
+
lex_values.map(&:value)
|
61
|
+
end
|
62
|
+
|
63
|
+
def active?
|
64
|
+
@active
|
65
|
+
end
|
66
|
+
|
67
|
+
def filled?
|
68
|
+
shape.list? ? values.any? : value != '' && !value.nil?
|
69
|
+
end
|
70
|
+
|
71
|
+
def blank?
|
72
|
+
!filled?
|
73
|
+
end
|
74
|
+
|
75
|
+
def resolve!(index: 0)
|
76
|
+
return if shape.list?
|
77
|
+
|
78
|
+
lex_value.resolve!(index: index)
|
36
79
|
end
|
37
80
|
|
38
81
|
def resolvable?
|
39
|
-
|
82
|
+
return false if shape.list?
|
83
|
+
|
84
|
+
lex_value.resolvable?
|
40
85
|
end
|
41
86
|
|
42
|
-
def
|
43
|
-
|
44
|
-
SlotDetail.new(name: name, resolutions: [], original_value: value)
|
45
|
-
end
|
87
|
+
def requestable?
|
88
|
+
active? && blank?
|
46
89
|
end
|
47
90
|
end
|
48
91
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Lex
|
5
|
+
class Conversation
|
6
|
+
module Type
|
7
|
+
class SlotValue
|
8
|
+
include Base
|
9
|
+
|
10
|
+
optional :original_value
|
11
|
+
optional :interpreted_value
|
12
|
+
required :resolved_values, default: -> { [] }
|
13
|
+
|
14
|
+
alias_method :value, :interpreted_value
|
15
|
+
alias_method :value=, :interpreted_value=
|
16
|
+
|
17
|
+
def to_lex
|
18
|
+
{
|
19
|
+
interpretedValue: interpreted_value,
|
20
|
+
originalValue: original_value,
|
21
|
+
resolvedValues: resolved_values
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def resolve!(index: 0)
|
26
|
+
self.interpreted_value = resolved(index: index)
|
27
|
+
end
|
28
|
+
|
29
|
+
def resolved(index: 0)
|
30
|
+
resolved_values.fetch(index) { interpreted_value }
|
31
|
+
end
|
32
|
+
|
33
|
+
def resolvable?
|
34
|
+
resolved_values.any?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-lex-conversation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Doyle
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-
|
15
|
+
date: 2021-07-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: shrink_wrap
|
@@ -74,30 +74,32 @@ files:
|
|
74
74
|
- lib/aws/lex/conversation/support/mixins/slot_elicitation.rb
|
75
75
|
- lib/aws/lex/conversation/type/base.rb
|
76
76
|
- lib/aws/lex/conversation/type/bot.rb
|
77
|
-
- lib/aws/lex/conversation/type/
|
77
|
+
- lib/aws/lex/conversation/type/checkpoint.rb
|
78
|
+
- lib/aws/lex/conversation/type/confirmation_state.rb
|
78
79
|
- lib/aws/lex/conversation/type/context.rb
|
80
|
+
- lib/aws/lex/conversation/type/dialog_action.rb
|
79
81
|
- lib/aws/lex/conversation/type/dialog_action_type.rb
|
80
82
|
- lib/aws/lex/conversation/type/enumeration.rb
|
81
83
|
- lib/aws/lex/conversation/type/event.rb
|
82
84
|
- lib/aws/lex/conversation/type/fulfillment_state.rb
|
85
|
+
- lib/aws/lex/conversation/type/input_mode.rb
|
83
86
|
- lib/aws/lex/conversation/type/intent.rb
|
84
87
|
- lib/aws/lex/conversation/type/intent_confidence.rb
|
88
|
+
- lib/aws/lex/conversation/type/interpretation.rb
|
85
89
|
- lib/aws/lex/conversation/type/invocation_source.rb
|
86
90
|
- lib/aws/lex/conversation/type/message.rb
|
87
91
|
- lib/aws/lex/conversation/type/message/content_type.rb
|
88
|
-
- lib/aws/lex/conversation/type/output_dialog_mode.rb
|
89
|
-
- lib/aws/lex/conversation/type/recent_intent_summary_view.rb
|
90
92
|
- lib/aws/lex/conversation/type/response.rb
|
91
93
|
- lib/aws/lex/conversation/type/response_card.rb
|
92
94
|
- lib/aws/lex/conversation/type/response_card/button.rb
|
93
|
-
- lib/aws/lex/conversation/type/
|
94
|
-
- lib/aws/lex/conversation/type/response_card/generic_attachment.rb
|
95
|
-
- lib/aws/lex/conversation/type/sentiment_label.rb
|
95
|
+
- lib/aws/lex/conversation/type/sentiment.rb
|
96
96
|
- lib/aws/lex/conversation/type/sentiment_response.rb
|
97
97
|
- lib/aws/lex/conversation/type/sentiment_score.rb
|
98
|
+
- lib/aws/lex/conversation/type/session_attributes.rb
|
99
|
+
- lib/aws/lex/conversation/type/session_state.rb
|
98
100
|
- lib/aws/lex/conversation/type/slot.rb
|
99
|
-
- lib/aws/lex/conversation/type/
|
100
|
-
- lib/aws/lex/conversation/type/
|
101
|
+
- lib/aws/lex/conversation/type/slot_shape.rb
|
102
|
+
- lib/aws/lex/conversation/type/slot_value.rb
|
101
103
|
- lib/aws/lex/conversation/type/time_to_live.rb
|
102
104
|
- lib/aws/lex/conversation/version.rb
|
103
105
|
homepage: https://github.com/amaabca/aws-lex-conversation
|
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|
123
|
-
rubygems_version: 3.1.
|
125
|
+
rubygems_version: 3.1.2
|
124
126
|
signing_key:
|
125
127
|
specification_version: 4
|
126
128
|
summary: AWS Lex Conversation Dialog Management
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aws
|
4
|
-
module Lex
|
5
|
-
class Conversation
|
6
|
-
module Type
|
7
|
-
class RecentIntentSummaryView
|
8
|
-
include Base
|
9
|
-
|
10
|
-
required :intent_name
|
11
|
-
required :slots
|
12
|
-
required :confirmation_status
|
13
|
-
required :dialog_action_type
|
14
|
-
required :slot_to_elicit
|
15
|
-
|
16
|
-
optional :fulfillment_state
|
17
|
-
optional :checkpoint_label
|
18
|
-
|
19
|
-
coerce(
|
20
|
-
slots: symbolize_hash!,
|
21
|
-
confirmation_status: ConfirmationStatus,
|
22
|
-
dialog_action_type: DialogActionType,
|
23
|
-
fulfillment_state: FulfillmentState
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aws
|
4
|
-
module Lex
|
5
|
-
class Conversation
|
6
|
-
module Type
|
7
|
-
class ResponseCard
|
8
|
-
class ContentType
|
9
|
-
include Enumeration
|
10
|
-
|
11
|
-
enumeration('application/vnd.amazonaws.card.generic')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aws
|
4
|
-
module Lex
|
5
|
-
class Conversation
|
6
|
-
module Type
|
7
|
-
class ResponseCard
|
8
|
-
class GenericAttachment
|
9
|
-
include Base
|
10
|
-
|
11
|
-
required :title
|
12
|
-
required :buttons
|
13
|
-
|
14
|
-
optional :sub_title
|
15
|
-
optional :image_url
|
16
|
-
optional :attachment_link_url
|
17
|
-
|
18
|
-
coerce(
|
19
|
-
buttons: Array[Button]
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|