watson-conversation 0.2.0 → 1.0.0
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/README.md +1 -1
- data/lib/watson/conversation.rb +13 -9
- data/lib/watson/conversation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe11b6d8c1895ef615fa872d31279618f8d074aa
|
4
|
+
data.tar.gz: 4d7f482d0fc4c55dc13a5af8daad1c52ba7517e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99725531c94eb90205983012687a09fa11274214f02a0a55101ca6608122d5e9ed7cdfbaeaeb2bd33c138949e89c0b8752170171464bcdab13a3ff3b9fa7ffd3
|
7
|
+
data.tar.gz: 224bf2efa4b37288498b5a84a9bb3b97a0e933e1473ec90d5dcbfad823d5b6741cf4b9faba61519a62eeb96fd258364f52e96b78de94a2d839290ae0e536f40a
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ manage = Watson::Conversation::ManageDialog.new(
|
|
28
28
|
password: [password],
|
29
29
|
workspace_id: [workspace_id],
|
30
30
|
# Where to link the freely-selected user name with the conversation_id
|
31
|
-
|
31
|
+
storage: "hash" or "uri for redis like 'redis://127.0.0.1:6379'"
|
32
32
|
)
|
33
33
|
|
34
34
|
# Get a greet message from a conversation service.
|
data/lib/watson/conversation.rb
CHANGED
@@ -131,6 +131,7 @@ module Watson
|
|
131
131
|
@mutex = Mutex.new
|
132
132
|
end
|
133
133
|
|
134
|
+
|
134
135
|
def users
|
135
136
|
@users
|
136
137
|
end
|
@@ -139,10 +140,12 @@ module Watson
|
|
139
140
|
def talk(user, question)
|
140
141
|
future_data = nil
|
141
142
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
143
|
+
@mutex.synchronize do
|
144
|
+
if @users.has_key?(user) == false
|
145
|
+
future_data = @cnv.talk("", "")
|
146
|
+
else
|
147
|
+
future_data = @cnv.talk(question, context = @users.fetch(user))
|
148
|
+
end
|
146
149
|
end
|
147
150
|
|
148
151
|
code, response = future_data.get_data()
|
@@ -155,15 +158,16 @@ module Watson
|
|
155
158
|
end
|
156
159
|
end
|
157
160
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
161
|
+
@mutex.synchronize do
|
162
|
+
if code == 200
|
163
|
+
@users.store(user, context)
|
164
|
+
else
|
165
|
+
@users.delete(user)
|
166
|
+
end
|
162
167
|
end
|
163
168
|
|
164
169
|
return {user: user, status_code: code, output: output_texts}.to_json
|
165
170
|
end
|
166
171
|
end
|
167
|
-
|
168
172
|
end
|
169
173
|
end
|