wit 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b70a97f9ec0b2c9b01f49983870ae7981cd0ca9a
4
- data.tar.gz: a575cf16cc6fd9ae10ce374617364c6edc6ea80a
3
+ metadata.gz: 8238be41a9a6f12e9b5ca05aa47e2df2bb174de7
4
+ data.tar.gz: 2cb886d831857aaffa697a17443714db24a38214
5
5
  SHA512:
6
- metadata.gz: 2f8a5583c0e72f940c9b7eff2c2cbcf31103b309ba040049b6f68bef599df4b14264fe99a5c18314c5202db928408157ad7d1bb38cef47bedce0bd46830bac09
7
- data.tar.gz: 58496e8a8bcb1f0c3183e00a611f713740932b2afbb2418534e244596dc303a1265a5681dbcb711907265283681e460c42094ba474573a27351d95369ba422e3
6
+ metadata.gz: 0777a1f0a9ca34416275ac36080a2caf8563edba3960d8e269a193106e5c03b1c5b18e21b9f6de01a806b884f65ac11d70a2fd4858343e1659f61baadc79f150
7
+ data.tar.gz: 7612bc8d01ba0499ea9a374251fbe2d9a8b1f884d9f1dde14d4fd64b90024585880ac49e6ebfee02afc0fedd10952f62b69a5a654d04cdc6ade03f1b4a2bc831
data/CHANGES.md CHANGED
@@ -1,6 +1,20 @@
1
+ ## v4.0.0
2
+
3
+ After a lot of internal dogfooding and bot building, we decided to change the API in a backwards-incompatible way. The changes are described below and aim to simplify user code and accommodate upcoming features.
4
+
5
+ See `./examples` to see how to use the new API.
6
+
7
+ ### Breaking changes
8
+
9
+ - `say` renamed to `send` to reflect that it deals with more than just text
10
+ - Removed built-in actions `merge` and `error`
11
+ - Actions signature simplified with `request` and `response` arguments
12
+ - INFO level replaces LOG level
13
+
1
14
  ## v3.4
2
15
 
3
16
  - allows for overriding API version, by setting `WIT_API_VERSION`
17
+ - `interactive()` mode
4
18
  - warns instead of throwing when validating actions
5
19
 
6
20
  ### breaking
data/README.md CHANGED
@@ -38,50 +38,30 @@ See the `examples` folder for more examples.
38
38
 
39
39
  ### Wit class
40
40
 
41
- The Wit constructor takes the following parameters:
42
- * `access_token` - the access token of your Wit instance
43
- * `actions` - the `Hash` with your actions
41
+ The Wit constructor takes a `Hash` with the following symbol keys:
42
+ * `:access_token` - the access token of your Wit instance
43
+ * `:actions` - the `Hash` with your actions
44
44
 
45
45
  The `actions` `Hash` has action names as keys, and action implementations as values.
46
46
  Action names are symbols, and action implementations are lambda functions (not `Proc`).
47
- You need to provide at least an implementation for the special actions `:say`, `:merge` and `:error`.
48
47
 
49
- A minimal `actions` `Hash` looks like this:
48
+ A minimal example looks like this:
50
49
  ```ruby
50
+ require 'wit'
51
+
51
52
  actions = {
52
- :say => -> (session_id, context, msg) {
53
- p msg
53
+ send: -> (request, response) {
54
+ puts("sending... #{response['text']}")
54
55
  },
55
- :merge => -> (session_id, context, entities, msg) {
56
- return context
57
- },
58
- :error => -> (session_id, context, error) {
59
- p error.message
56
+ my_action: -> (request) {
57
+ return request['context']
60
58
  },
61
59
  }
62
- ```
63
-
64
- A custom action takes the following parameters:
65
- * `session_id` - a unique identifier describing the user session
66
- * `context` - the `Hash` representing the session state
67
-
68
- Example:
69
- ```ruby
70
- require 'wit'
71
- client = Wit.new access_token, actions
72
- ```
73
-
74
- ### Logging
75
-
76
- Default logging is to `STDOUT` with `INFO` level.
77
60
 
78
- You can setup your logging level as follows:
79
- ```ruby
80
- Wit.logger.level = Logger::WARN
61
+ client = Wit.new(access_token: access_token, actions: actions)
81
62
  ```
82
- See the [Logger class](http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html) docs for more information.
83
63
 
84
- ### message
64
+ ### .message()
85
65
 
86
66
  The Wit [message API](https://wit.ai/docs/http/20160330#get-intent-via-text-link).
87
67
 
@@ -90,11 +70,11 @@ Takes the following parameters:
90
70
 
91
71
  Example:
92
72
  ```ruby
93
- resp = client.message 'what is the weather in London?'
94
- p "Yay, got Wit.ai response: #{resp}"
73
+ rsp = client.message('what is the weather in London?')
74
+ puts("Yay, got Wit.ai response: #{rsp}")
95
75
  ```
96
76
 
97
- ### run_actions
77
+ ### .run_actions()
98
78
 
99
79
  A higher-level method to the Wit converse API.
100
80
 
@@ -108,13 +88,13 @@ Example:
108
88
  ```ruby
109
89
  session = 'my-user-session-42'
110
90
  context0 = {}
111
- context1 = client.run_actions session, 'what is the weather in London?', context0
91
+ context1 = client.run_actions(session, 'what is the weather in London?', context0)
112
92
  p "The session state is now: #{context1}"
113
- context2 = client.run_actions session, 'and in Brussels?', context1
93
+ context2 = client.run_actions(session, 'and in Brussels?', context1)
114
94
  p "The session state is now: #{context2}"
115
95
  ```
116
96
 
117
- ### converse
97
+ ### .converse()
118
98
 
119
99
  The low-level Wit [converse API](https://wit.ai/docs/http/20160330#converse-link).
120
100
 
@@ -125,12 +105,11 @@ Takes the following parameters:
125
105
 
126
106
  Example:
127
107
  ```ruby
128
- resp = client.converse 'my-user-session-42', 'what is the weather in London?', {}
129
- p "Yay, got Wit.ai response: #{resp}"
108
+ rsp = client.converse('my-user-session-42', 'what is the weather in London?', {})
109
+ puts("Yay, got Wit.ai response: #{rsp}")
130
110
  ```
131
111
 
132
-
133
- ### interactive
112
+ ### .interactive()
134
113
 
135
114
  Starts an interactive conversation with your bot.
136
115
 
@@ -141,6 +120,15 @@ client.interactive
141
120
 
142
121
  See the [docs](https://wit.ai/docs) for more information.
143
122
 
123
+ ### Logging
124
+
125
+ Default logging is to `STDOUT` with `INFO` level.
126
+
127
+ You can setup your logging level as follows:
128
+ ```ruby
129
+ Wit.logger.level = Logger::WARN
130
+ ```
131
+ See the [Logger class](http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html) docs for more information.
144
132
 
145
133
  ## Thanks
146
134
 
@@ -0,0 +1,18 @@
1
+ require 'wit'
2
+
3
+ if ARGV.length == 0
4
+ puts("usage: #{$0} <wit-access-token>")
5
+ exit 1
6
+ end
7
+
8
+ access_token = ARGV[0]
9
+ ARGV.shift
10
+
11
+ actions = {
12
+ send: -> (request, response) {
13
+ puts("sending... #{response['text']}")
14
+ },
15
+ }
16
+
17
+ client = Wit.new(access_token: access_token, actions: actions)
18
+ client.interactive
@@ -1,10 +1,16 @@
1
1
  require 'wit'
2
2
 
3
+ if ARGV.length == 0
4
+ puts("usage: #{$0} <wit-access-token>")
5
+ exit 1
6
+ end
7
+
8
+ access_token = ARGV[0]
9
+ ARGV.shift
10
+
3
11
  # Joke example
4
12
  # See https://wit.ai/patapizza/example-joke
5
13
 
6
- access_token = 'YOUR_ACCESS_TOKEN'
7
-
8
14
  def first_entity_value(entities, entity)
9
15
  return nil unless entities.has_key? entity
10
16
  val = entities[entity][0]['value']
@@ -27,27 +33,28 @@ all_jokes = {
27
33
  }
28
34
 
29
35
  actions = {
30
- :say => -> (session_id, context, msg) {
31
- p msg
36
+ send: -> (request, response) {
37
+ puts("sending... #{response['text']}")
32
38
  },
33
- :merge => -> (session_id, context, entities, msg) {
39
+ merge: -> (request) {
40
+ context = request['context']
41
+ entities = request['entities']
42
+
34
43
  context.delete 'joke'
35
44
  context.delete 'ack'
36
- category = first_entity_value entities, 'category'
45
+ category = first_entity_value(entities, 'category')
37
46
  context['category'] = category unless category.nil?
38
- sentiment = first_entity_value entities, 'sentiment'
47
+ sentiment = first_entity_value(entities, 'sentiment')
39
48
  context['ack'] = sentiment == 'positive' ? 'Glad you liked it.' : 'Hmm.' unless sentiment.nil?
40
49
  return context
41
50
  },
42
- :error => -> (session_id, context, error) {
43
- p error.message
44
- },
45
- :'select-joke' => -> (session_id, context) {
46
- context['joke'] = all_jokes[context['cat'] || 'default'].sample
51
+ :'select-joke' => -> (request) {
52
+ context = request['context']
53
+
54
+ context['joke'] = all_jokes[context['category'] || 'default'].sample
47
55
  return context
48
56
  },
49
57
  }
50
- client = Wit.new access_token, actions
51
58
 
52
- session_id = 'my-user-id-42'
53
- client.run_actions session_id, 'tell me a joke about tech', {}
59
+ client = Wit.new(access_token: access_token, actions: actions)
60
+ client.interactive
@@ -1,14 +1,16 @@
1
1
  require 'wit'
2
2
 
3
- # Quickstart example
4
- # See https://wit.ai/l5t/Quickstart
5
-
6
- access_token = ARGV.shift
7
- unless access_token
8
- puts 'usage: ruby examples/quickstart.rb <access-token>'
9
- exit
3
+ if ARGV.length == 0
4
+ puts("usage: #{$0} <wit-access-token>")
5
+ exit 1
10
6
  end
11
7
 
8
+ access_token = ARGV[0]
9
+ ARGV.shift
10
+
11
+ # Quickstart example
12
+ # See https://wit.ai/ar7hur/Quickstart
13
+
12
14
  def first_entity_value(entities, entity)
13
15
  return nil unless entities.has_key? entity
14
16
  val = entities[entity][0]['value']
@@ -17,21 +19,24 @@ def first_entity_value(entities, entity)
17
19
  end
18
20
 
19
21
  actions = {
20
- :say => -> (session_id, context, msg) {
21
- p msg
22
+ send: -> (request, response) {
23
+ puts("sending... #{response['text']}")
22
24
  },
23
- :merge => -> (session_id, context, entities, msg) {
24
- loc = first_entity_value entities, 'location'
25
- context['loc'] = loc unless loc.nil?
26
- return context
27
- },
28
- :error => -> (session_id, context, error) {
29
- p error.message
30
- },
31
- :'fetch-weather' => -> (session_id, context) {
32
- context['forecast'] = 'sunny'
25
+ getForecast: -> (request) {
26
+ context = request['context']
27
+ entities = request['entities']
28
+
29
+ loc = first_entity_value(entities, 'location')
30
+ if loc
31
+ context['forecast'] = 'sunny'
32
+ else
33
+ context['missingLocation'] = true
34
+ context.delete('forecast')
35
+ end
36
+
33
37
  return context
34
38
  },
35
39
  }
36
- client = Wit.new access_token, actions
40
+
41
+ client = Wit.new(access_token: access_token, actions: actions)
37
42
  client.interactive
data/lib/wit.rb CHANGED
@@ -6,149 +6,195 @@ require 'securerandom'
6
6
  WIT_API_HOST = ENV['WIT_URL'] || 'https://api.wit.ai'
7
7
  WIT_API_VERSION = ENV['WIT_API_VERSION'] || '20160516'
8
8
  DEFAULT_MAX_STEPS = 5
9
+ LEARN_MORE = 'Learn more at https://wit.ai/docs/quickstart'
9
10
 
10
11
  class WitException < Exception
11
12
  end
12
13
 
13
- def req(access_token, meth_class, path, params={}, payload={})
14
+ def req(logger, access_token, meth_class, path, params={}, payload={})
14
15
  uri = URI(WIT_API_HOST + path)
15
- uri.query = URI.encode_www_form params
16
+ uri.query = URI.encode_www_form(params)
16
17
 
17
- request = meth_class.new uri
18
+ logger.debug("#{meth_class} #{uri}")
19
+
20
+ request = meth_class.new(uri)
18
21
  request['authorization'] = 'Bearer ' + access_token
19
22
  request['accept'] = 'application/vnd.wit.' + WIT_API_VERSION + '+json'
20
23
  request.add_field 'Content-Type', 'application/json'
21
24
  request.body = payload.to_json
22
25
 
23
- Net::HTTP.start uri.host, uri.port, {:use_ssl => uri.scheme == 'https'} do |http|
24
- rsp = http.request request
25
- raise WitException.new "HTTP error code=#{rsp.code}" unless rsp.code.to_i <= 200
26
- json = JSON.parse rsp.body
27
- raise WitException.new "Wit responded with an error: #{json['error']}" if json.has_key? 'error'
26
+ Net::HTTP.start(uri.host, uri.port, {:use_ssl => uri.scheme == 'https'}) do |http|
27
+ rsp = http.request(request)
28
+ if rsp.code.to_i != 200
29
+ raise WitException.new("HTTP error code=#{rsp.code}")
30
+ end
31
+ json = JSON.parse(rsp.body)
32
+ if json.has_key?('error')
33
+ raise WitException.new("Wit responded with an error: #{json['error']}")
34
+ end
35
+ logger.debug("#{meth_class} #{uri} #{json}")
28
36
  json
29
37
  end
30
38
  end
31
39
 
32
- def validate_actions(actions)
33
- learn_more = 'Learn more at https://wit.ai/docs/quickstart'
34
- Wit.logger.warn 'The second parameter should be a Hash' unless actions.is_a? Hash
35
- [:say, :merge, :error].each do |action|
36
- Wit.logger.warn "The #{action} action is missing. #{learn_more}" unless actions.has_key? action
40
+ def validate_actions(logger, actions)
41
+ [:send].each do |action|
42
+ if !actions.has_key?(action)
43
+ logger.warn "The #{action} action is missing. #{LEARN_MORE}"
44
+ end
37
45
  end
38
46
  actions.each_pair do |k, v|
39
- Wit.logger.warn "The '#{k}' action name should be a symbol" unless k.is_a? Symbol
40
- Wit.logger.warn "The '#{k}' action should be a lambda function" unless v.respond_to? :call and v.lambda?
41
- Wit.logger.warn "The \'say\' action should take 3 arguments: session_id, context, msg. #{learn_more}" if k == :say and v.arity != 3
42
- Wit.logger.warn "The \'merge\' action should take 4 arguments: session_id, context, entities, msg. #{learn_more}" if k == :merge and v.arity != 4
43
- Wit.logger.warn "The \'error\' action should take 3 arguments: session_id, context, error. #{learn_more}" if k == :error and v.arity != 3
44
- Wit.logger.warn "The '#{k}' action should take 2 arguments: session_id, context. #{learn_more}" if k != :say and k != :merge and k != :error and v.arity != 2
47
+ if !k.is_a?(Symbol)
48
+ logger.warn "The '#{k}' action name should be a symbol"
49
+ end
50
+ if !(v.respond_to?(:call) && v.lambda?)
51
+ logger.warn "The '#{k}' action should be a lambda function"
52
+ end
53
+ if k == :send && v.arity != 2
54
+ logger.warn "The \'send\' action should take 2 arguments: request and response. #{LEARN_MORE}"
55
+ end
56
+ if k != :send && v.arity != 1
57
+ logger.warn "The '#{k}' action should take 1 argument: request. #{LEARN_MORE}"
58
+ end
45
59
  end
46
60
  return actions
47
61
  end
48
62
 
49
63
  class Wit
50
- class << self
51
- attr_writer :logger
64
+ def initialize(opts = {})
65
+ @access_token = opts[:access_token]
52
66
 
53
- def logger
54
- @logger ||= begin
55
- $stdout.sync = true
56
- Logger.new(STDOUT)
57
- end.tap { |logger| logger.level = Logger::INFO }
67
+ if opts[:logger]
68
+ @logger = opts[:logger]
58
69
  end
59
- end
60
70
 
61
- def initialize(access_token, actions)
62
- @access_token = access_token
63
- @actions = validate_actions actions
71
+ if opts[:actions]
72
+ @actions = validate_actions(logger, opts[:actions])
73
+ end
64
74
  end
65
75
 
66
76
  def logger
67
- self.class.logger
77
+ @logger ||= begin
78
+ x = Logger.new(STDOUT)
79
+ x.level = Logger::INFO
80
+ x
81
+ end
68
82
  end
69
83
 
70
84
  def message(msg)
71
- logger.debug "Message request: msg=#{msg}"
72
85
  params = {}
73
86
  params[:q] = msg unless msg.nil?
74
- res = req @access_token, Net::HTTP::Get, '/message', params
75
- logger.debug "Message response: #{res}"
87
+ res = req(logger, @access_token, Net::HTTP::Get, '/message', params)
76
88
  return res
77
89
  end
78
90
 
79
91
  def converse(session_id, msg, context={})
80
- logger.debug "Converse request: session_id=#{session_id} msg=#{msg} context=#{context}"
81
- raise WitException.new 'context should be a Hash' unless context.is_a? Hash
92
+ if !context.is_a?(Hash)
93
+ raise WitException.new('context should be a Hash')
94
+ end
82
95
  params = {}
83
96
  params[:q] = msg unless msg.nil?
84
97
  params[:session_id] = session_id
85
- res = req @access_token, Net::HTTP::Post, '/converse', params, context
86
- logger.debug "Converse response: #{res}"
98
+ res = req(logger, @access_token, Net::HTTP::Post, '/converse', params, context)
87
99
  return res
88
100
  end
89
101
 
90
- def run_actions_(session_id, message, context, max_steps, user_message)
91
- raise WitException.new 'max iterations reached' unless max_steps > 0
102
+ def __run_actions(session_id, message, context, i)
103
+ if i <= 0
104
+ raise WitException.new('Max steps reached, stopping.')
105
+ end
106
+ json = converse(session_id, message, context)
107
+ if json['type'].nil?
108
+ raise WitException.new('Couldn\'t find type in Wit response')
109
+ end
92
110
 
93
- rst = converse session_id, message, context
94
- raise WitException.new 'couldn\'t find type in Wit response' unless rst.has_key? 'type'
111
+ logger.debug("Context: #{context}")
112
+ logger.debug("Response type: #{json['type']}")
95
113
 
96
- type = rst['type']
114
+ # backwards-compatibility with API version 20160516
115
+ if json['type'] == 'merge'
116
+ json['type'] = 'action'
117
+ json['action'] = 'merge'
118
+ end
97
119
 
98
- return context if type == 'stop'
99
- if type == 'msg'
100
- raise WitException.new 'unknown action: say' unless @actions.has_key? :say
101
- msg = rst['msg']
102
- logger.info "Executing say with: #{msg}"
103
- @actions[:say].call session_id, context.clone, msg
104
- elsif type == 'merge'
105
- raise WitException.new 'unknown action: merge' unless @actions.has_key? :merge
106
- logger.info 'Executing merge'
107
- context = @actions[:merge].call session_id, context.clone, rst['entities'], user_message
108
- if context.nil?
109
- logger.warn 'missing context - did you forget to return it?'
110
- context = {}
111
- end
112
- elsif type == 'action'
113
- action = rst['action'].to_sym
114
- raise WitException.new "unknown action: #{action}" unless @actions.has_key? action
115
- logger.info "Executing action #{action}"
116
- context = @actions[action].call session_id, context.clone
120
+ if json['type'] == 'error'
121
+ raise WitException.new('Oops, I don\'t know what to do.')
122
+ end
123
+
124
+ if json['type'] == 'stop'
125
+ return context
126
+ end
127
+
128
+ request = {
129
+ 'session_id' => session_id,
130
+ 'context' => context.clone,
131
+ 'text' => message,
132
+ 'entities' => json['entities']
133
+ }
134
+ if json['type'] == 'msg'
135
+ throw_if_action_missing(:send)
136
+ response = {
137
+ 'text' => json['msg'],
138
+ 'quickreplies' => json['quickreplies'],
139
+ }
140
+ @actions[:send].call(request, response)
141
+ elsif json['type'] == 'action'
142
+ action = json['action'].to_sym
143
+ throw_if_action_missing(action)
144
+ context = @actions[action].call(request)
117
145
  if context.nil?
118
- logger.warn 'missing context - did you forget to return it?'
146
+ logger.warn('missing context - did you forget to return it?')
119
147
  context = {}
120
148
  end
121
- elsif type == 'error'
122
- raise WitException.new 'unknown action: error' unless @actions.has_key? :error
123
- logger.info 'Executing error'
124
- @actions[:error].call session_id, context.clone, WitException.new('Oops, I don\'t know what to do.')
125
149
  else
126
- raise WitException.new "unknown type: #{type}"
150
+ raise WitException.new("unknown type: #{json['type']}")
127
151
  end
128
- return run_actions_ session_id, nil, context, max_steps - 1, user_message
152
+
153
+ return __run_actions(session_id, nil, context, i - 1)
129
154
  end
130
155
 
131
156
  def run_actions(session_id, message, context={}, max_steps=DEFAULT_MAX_STEPS)
132
- raise WitException.new 'context should be a Hash' unless context.is_a? Hash
133
- return run_actions_ session_id, message, context, max_steps, message
157
+ if !@actions
158
+ throw_must_have_actions
159
+ end
160
+ if !context.is_a?(Hash)
161
+ raise WitException.new('context should be a Hash')
162
+ end
163
+ return __run_actions(session_id, message, context, max_steps)
134
164
  end
135
165
 
136
166
  def interactive(context={}, max_steps=DEFAULT_MAX_STEPS)
137
- session_id = SecureRandom.uuid
167
+ if !@actions
168
+ throw_must_have_actions
169
+ end
138
170
 
171
+ session_id = SecureRandom.uuid
139
172
  while true
140
173
  print '> '
141
174
  msg = gets.strip
175
+ if msg == ''
176
+ next
177
+ end
142
178
 
143
179
  begin
144
180
  context = run_actions(session_id, msg, context, max_steps)
145
181
  rescue WitException => exp
146
- p exp.message
182
+ logger.error("error: #{exp.message}")
147
183
  end
148
184
  end
149
185
  rescue Interrupt => _exp
150
186
  puts
151
187
  end
152
188
 
153
- private :run_actions_
189
+ def throw_if_action_missing(action_name)
190
+ if !@actions.has_key?(action_name)
191
+ raise WitException.new("unknown action: #{action_name}")
192
+ end
193
+ end
194
+
195
+ def throw_must_have_actions()
196
+ raise WitException.new('You must provide the `actions` parameter to be able to use runActions. ' + LEARN_MORE)
197
+ end
198
+
199
+ private :__run_actions
154
200
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'wit'
3
- s.version = '3.4.0'
3
+ s.version = '4.0.0'
4
4
  s.date = Date.today.to_s
5
5
  s.summary = 'Ruby SDK for Wit.ai'
6
6
  s.description = 'Ruby SDK for Wit.ai'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Wit Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby SDK for Wit.ai
14
14
  email: help@wit.ai
@@ -21,9 +21,9 @@ files:
21
21
  - Gemfile
22
22
  - LICENSE
23
23
  - README.md
24
+ - examples/basic.rb
24
25
  - examples/joke.rb
25
26
  - examples/quickstart.rb
26
- - examples/template.rb
27
27
  - lib/wit.rb
28
28
  - wit.gemspec
29
29
  homepage: https://wit.ai
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 2.4.5
49
+ rubygems_version: 2.5.1
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: Ruby SDK for Wit.ai
@@ -1,19 +0,0 @@
1
- require 'wit'
2
-
3
- access_token = 'YOUR_ACCESS_TOKEN'
4
-
5
- actions = {
6
- :say => -> (session_id, context, msg) {
7
- p msg
8
- },
9
- :merge => -> (session_id, context, entities, msg) {
10
- return context
11
- },
12
- :error => -> (session_id, context, error) {
13
- p error.message
14
- },
15
- }
16
- client = Wit.new access_token, actions
17
-
18
- session_id = 'my-user-id-42'
19
- client.run_actions session_id, 'your message', {}