watson-assistant 1.0.5 → 1.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7ee9693b9ba30e8f47c2593223454ea6abafb606b74cfdb3f1a5598438fd1b7
|
4
|
+
data.tar.gz: d2c70aeabbae5a0091a647e2f4ba0a94c7732eed4951730abded88d168d6b617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89ad65776d04ab7c301fce0e432110b4f85325f2c8870700b02b479893aac4ac1c9cc4f900f000477164e31f11633625c03bfa785abe50f0ea8e73ca651a35e
|
7
|
+
data.tar.gz: '09f5bc7341ec7a0c75a1b8d6fafd0f939c172aa8d3285a05d7b3569257c3a0e982c9c08736703e70ea27ab9571cd3724a757607ec16fddb5b60df85a1b543f47'
|
data/Gemfile.lock
CHANGED
Binary file
|
Binary file
|
@@ -6,16 +6,14 @@ module Watson
|
|
6
6
|
|
7
7
|
class Dialog
|
8
8
|
def initialize(config)
|
9
|
-
|
10
|
-
password = config[:password]
|
9
|
+
auth = config[:auth]
|
11
10
|
workspace_id = config[:workspace_id]
|
12
11
|
region = config[:region] || "gateway.watsonplatform.net"
|
13
|
-
|
14
|
-
url = "https://#{
|
15
|
-
version="2018-02-16"
|
12
|
+
|
13
|
+
url = "https://#{auth}@#{region}/assistant/api"
|
14
|
+
version = "2018-02-16"
|
16
15
|
@endpoint = "#{url}/v1/workspaces/#{workspace_id}/message?version=#{version}"
|
17
16
|
end
|
18
|
-
|
19
17
|
|
20
18
|
def talk(question, context)
|
21
19
|
if context == ""
|
@@ -6,11 +6,25 @@ module Watson
|
|
6
6
|
module Assistant
|
7
7
|
class Manager
|
8
8
|
def initialize(config)
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
@config = config
|
10
|
+
check = check_config()
|
11
|
+
|
12
|
+
if check == true
|
13
|
+
create_dialog()
|
14
|
+
prepare_storage()
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_dialog
|
20
|
+
@dlg = Dialog.new(
|
21
|
+
@config
|
12
22
|
)
|
13
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def prepare_storage
|
27
|
+
storage = @config[:storage] || "hash"
|
14
28
|
if storage == "hash"
|
15
29
|
@users = Hash.new
|
16
30
|
else
|
@@ -19,8 +33,28 @@ module Watson
|
|
19
33
|
end
|
20
34
|
|
21
35
|
|
22
|
-
def
|
23
|
-
@
|
36
|
+
def check_config()
|
37
|
+
if @config[:apikey]
|
38
|
+
if @config[:username] || @config[:password]
|
39
|
+
puts "Error: 'Both API key' and 'Username and Password' are used"
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
@config[:auth] = "apikey:#{@config[:apikey]}"
|
43
|
+
|
44
|
+
elsif @config[:username] && @config[:password]
|
45
|
+
@config[:auth] = "#{@config[:username]}:#{@config[:password]}"
|
46
|
+
|
47
|
+
else
|
48
|
+
puts "Error: Not authorized"
|
49
|
+
return false
|
50
|
+
end
|
51
|
+
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def has_dlg?
|
57
|
+
return @dlg
|
24
58
|
end
|
25
59
|
|
26
60
|
|
@@ -38,9 +72,9 @@ module Watson
|
|
38
72
|
future_data = nil
|
39
73
|
|
40
74
|
if @users.has_key?(user) == false
|
41
|
-
code, body = @
|
75
|
+
code, body = @dlg.talk("", "")
|
42
76
|
else
|
43
|
-
code, body = @
|
77
|
+
code, body = @dlg.talk(question, context = @users.fetch(user))
|
44
78
|
end
|
45
79
|
|
46
80
|
if code == 200
|
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.6
|
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-
|
11
|
+
date: 2018-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,8 @@ 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
|
102
104
|
- lib/watson/assistant/dialog.rb
|
103
105
|
- lib/watson/assistant/manager.rb
|
104
106
|
- lib/watson/assistant/version.rb
|