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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +27 -3
- data/lib/watson/assistant.rb +0 -1
- data/lib/watson/assistant/dialog.rb +1 -1
- data/lib/watson/assistant/manager.rb +30 -2
- data/lib/watson/assistant/version.rb +1 -1
- metadata +2 -4
- data/lib/watson/assistant/.dialog.rb.swp +0 -0
- data/lib/watson/assistant/.manager.rb.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f3a53aef537d855168eb7a8fb28cf8fa9b5ebda316c5e010e718c708f37d580
|
4
|
+
data.tar.gz: 898f53f0c7f1a6a1d45274b7adf1bc8bf03e5ea932f608ff19b4010bec747dbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc2e152f50e592f867d04136e26cfc5b77e87154295daa278f09cc159fb441588b58953580a15ede48e49cfca7ee2da9a9ad73556966175bef0a0df93cbed84
|
7
|
+
data.tar.gz: ca5903efd2910ba17202ecb9ace391029ecd7fbbb37eca8a17b046ec7966d211301f95c19e35704199b6590d2bfd97a732045e0fbe46be72ebedcd4dc7122ce1
|
data/Gemfile.lock
CHANGED
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
|
-
##
|
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
|
+
|
data/lib/watson/assistant.rb
CHANGED
@@ -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-
|
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
|
-
|
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
|
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))
|
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.
|
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-
|
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
|
Binary file
|
Binary file
|