watson-assistant 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4184a78f5c2e115cc5ec7d90a4a00153ab8adc9b89320ad4464e7f0fb40ea3bf
4
- data.tar.gz: edab7b5c5b5dbd2aa8995a75001bd387621eac26529066e60135e802217cdd6a
3
+ metadata.gz: 0f3a53aef537d855168eb7a8fb28cf8fa9b5ebda316c5e010e718c708f37d580
4
+ data.tar.gz: 898f53f0c7f1a6a1d45274b7adf1bc8bf03e5ea932f608ff19b4010bec747dbb
5
5
  SHA512:
6
- metadata.gz: cb984c4324fa4c8447b6d480bdc891d1ad74b0eb2f7df0fc50f6cc75be69f90fcd43259898d3ff57bc1fb523b2db0ee0638bc7f3f11cb5f09b8eb517a4b9fd7e
7
- data.tar.gz: 26439b05d231e66f984bb95936c1263c5b204a52da87e5726e90f10a675ba222107e1d4c3106fe10fa1438ce7d7d65afa2e301a3c218a2548801d97d9e16b40a
6
+ metadata.gz: 6fc2e152f50e592f867d04136e26cfc5b77e87154295daa278f09cc159fb441588b58953580a15ede48e49cfca7ee2da9a9ad73556966175bef0a0df93cbed84
7
+ data.tar.gz: ca5903efd2910ba17202ecb9ace391029ecd7fbbb37eca8a17b046ec7966d211301f95c19e35704199b6590d2bfd97a732045e0fbe46be72ebedcd4dc7122ce1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watson-assistant (1.0.5)
4
+ watson-assistant (1.0.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -87,22 +87,46 @@ puts response1 = manager.talk("user1", "")
87
87
  puts response2 = manager.talk("user1", "I would like you to ...")
88
88
  ```
89
89
 
90
- ## Development
90
+ ## Advanced usage
91
+ ### Edit context variables
92
+ The SDK exposes the access to a context variable. You can edit a context variable. I
93
+ The most common use cases to edit a context variable is that when you call cloud function nodes from Watson Assistant instances. You do not have to store credentials in the Watson Assistant workspace. Instead, pass them from the client application as part of context.
94
+ ```ruby
95
+ section = {"my_credentials"=> {
96
+ "user": "user_for_calling_functions",
97
+ "password": "password_for_calling_functions"
98
+ }
99
+ }
100
+
101
+ manager.update_context_section(user: "user1", key: "private", value: section))
102
+
103
+ ```
104
+
105
+ Other use cases to operate a context variable
106
+ ```ruby
107
+ manager.read_context(user: "user1")
108
+ manager.read_context_section(user: "user1", key: "conversation_id"
109
+ manager.delete_context_section(user: "user1", key: "private")
110
+
111
+ ```
112
+
91
113
 
114
+ ## Development
92
115
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
116
 
94
117
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
118
 
96
- ## Contributing
97
119
 
120
+ ## Contributing
98
121
  Bug reports and pull requests are welcome on GitHub at https://github.com/alpha-netzilla/watson-assistant. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
99
122
 
100
123
 
101
124
  ## License
102
-
103
125
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
104
126
 
127
+
105
128
  ## Authors
106
129
  * http://alpha-netzilla.blogspot.com/
107
130
 
108
131
  [wc]: http://www.ibm.com/watson/developercloud/doc/assistant/index.html
132
+
@@ -1,6 +1,5 @@
1
1
  require 'rest-client'
2
2
  require "json"
3
- require "thread"
4
3
  require "redis"
5
4
  require "watson/assistant/manager"
6
5
 
@@ -11,7 +11,7 @@ module Watson
11
11
  region = config[:region] || "gateway.watsonplatform.net"
12
12
 
13
13
  url = "https://#{auth}@#{region}/assistant/api"
14
- version = "2018-02-16"
14
+ version = "2018-09-20"
15
15
  @endpoint = "#{url}/v1/workspaces/#{workspace_id}/message?version=#{version}"
16
16
  end
17
17
 
@@ -12,7 +12,7 @@ module Watson
12
12
  if check == true
13
13
  create_dialog()
14
14
  prepare_storage()
15
- end
15
+ end
16
16
 
17
17
  end
18
18
 
@@ -36,7 +36,7 @@ module Watson
36
36
  def check_config()
37
37
  if @config[:apikey]
38
38
  if @config[:username] || @config[:password]
39
- puts "Error: 'Both API key' and 'Username and Password' are used"
39
+ puts "Error: 'Both API key' and 'Username/Password' are used"
40
40
  return false
41
41
  end
42
42
  @config[:auth] = "apikey:#{@config[:apikey]}"
@@ -92,9 +92,37 @@ module Watson
92
92
 
93
93
  return {user: user, status_code: code, output: output}.to_json
94
94
  end
95
+
96
+
97
+ def read_context(user:)
98
+ context = @users.fetch(user)
99
+ end
100
+
101
+
102
+ def read_context_section(user:, key:)
103
+ context = @users.fetch(user)
104
+ return context[key]
105
+ end
106
+
107
+
108
+ def update_context_section(user:, key:, value:)
109
+ context = @users.fetch(user)
110
+ context[key] = value
111
+ @users.store(user, context)
112
+ return context
113
+ end
114
+
115
+
116
+ def delete_context_section(user:, key:)
117
+ context = @users.fetch(user)
118
+ context.delete(key)
119
+ @users.store(user, context)
120
+ return context
121
+ end
95
122
  end
96
123
 
97
124
 
125
+
98
126
  class Redis < ::Redis
99
127
  def fetch(user)
100
128
  JSON.parse(get(user))
@@ -1,5 +1,5 @@
1
1
  module Watson
2
2
  module Assistant
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watson-assistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - alpha.netzilla
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,8 +99,6 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - lib/watson/assistant.rb
102
- - lib/watson/assistant/.dialog.rb.swp
103
- - lib/watson/assistant/.manager.rb.swp
104
102
  - lib/watson/assistant/dialog.rb
105
103
  - lib/watson/assistant/manager.rb
106
104
  - lib/watson/assistant/version.rb