ibm_watson 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/ibm_watson/assistant_v1.rb +76 -21
- data/lib/ibm_watson/discovery_v1.rb +4 -2
- data/lib/ibm_watson/speech_to_text_v1.rb +92 -40
- data/lib/ibm_watson/version.rb +1 -1
- data/test/integration/test_speech_to_text_v1.rb +8 -8
- data/test/unit/test_assistant_v1.rb +41 -12
- data/test/unit/test_discovery_v1.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f867b01332162f178deb7bb0382b95c2dc90254ff079f840b3fb64f6c8b2102
|
4
|
+
data.tar.gz: f5ede7a5fe4313e2e921ad7bac8700be471d250b89c3f03ad5b18c891d0feae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 732f0fa20dfe3c4d29b48cb6cfcb6574eaac7188bf8b496af4e103a50ea258c3accef20f627b0e9a9e76d75e1dc7eed24511b81cfb47848a121d939403e92981
|
7
|
+
data.tar.gz: 812d8afe21c7076c9ad8f9009ea2627621dbc0c179d825f5d34a9abda2ec5d0ae13aad11102ffa341e644b4d5b490b56954010943072c49b7549ab1ef425320b
|
data/README.md
CHANGED
@@ -249,7 +249,7 @@ assistant.configure_http_client(
|
|
249
249
|
|
250
250
|
## Using Websockets
|
251
251
|
|
252
|
-
The Speech-to-Text service supports websockets with the `
|
252
|
+
The Speech-to-Text service supports websockets with the `recognize_using_websocket` method. The method accepts a custom callback class. The `eventmachine` loop that the websocket uses blocks the main thread by default. Here is an example of using the websockets method:
|
253
253
|
|
254
254
|
```ruby
|
255
255
|
require "ibm_watson"
|
@@ -260,7 +260,7 @@ speech_to_text = IBMWatson::SpeechToTextV1.new(
|
|
260
260
|
username: "<username>",
|
261
261
|
password: "<password>"
|
262
262
|
)
|
263
|
-
websocket = speech_to_text.
|
263
|
+
websocket = speech_to_text.recognize_using_websocket(
|
264
264
|
audio: audio_file,
|
265
265
|
recognize_callback: callback,
|
266
266
|
interim_results: true
|
@@ -271,6 +271,7 @@ thr = Thread.new do # Start the websocket inside of a thread
|
|
271
271
|
end
|
272
272
|
thr.join # Wait for the thread to finish before ending the program or running other code
|
273
273
|
```
|
274
|
+
Note: `recognize_with_websocket` has been **deprecated** in favor of **`recognize_using_websocket`**
|
274
275
|
|
275
276
|
## Ruby version
|
276
277
|
|
@@ -255,7 +255,7 @@ module IBMWatson
|
|
255
255
|
end
|
256
256
|
|
257
257
|
##
|
258
|
-
# @!method create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil)
|
258
|
+
# @!method create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, system_settings: nil)
|
259
259
|
# Create workspace.
|
260
260
|
# Create a workspace based on component objects. You must provide workspace
|
261
261
|
# components defining the content of the new workspace.
|
@@ -275,8 +275,9 @@ module IBMWatson
|
|
275
275
|
# @param metadata [Object] Any metadata related to the workspace.
|
276
276
|
# @param learning_opt_out [Boolean] Whether training data from the workspace can be used by IBM for general service
|
277
277
|
# improvements. `true` indicates that workspace training data is not to be used.
|
278
|
+
# @param system_settings [WorkspaceSystemSettings] Global settings for the workspace.
|
278
279
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
279
|
-
def create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil)
|
280
|
+
def create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, system_settings: nil)
|
280
281
|
headers = {
|
281
282
|
}
|
282
283
|
params = {
|
@@ -291,7 +292,8 @@ module IBMWatson
|
|
291
292
|
"dialog_nodes" => dialog_nodes,
|
292
293
|
"counterexamples" => counterexamples,
|
293
294
|
"metadata" => metadata,
|
294
|
-
"learning_opt_out" => learning_opt_out
|
295
|
+
"learning_opt_out" => learning_opt_out,
|
296
|
+
"system_settings" => system_settings
|
295
297
|
}
|
296
298
|
method_url = "/v1/workspaces"
|
297
299
|
response = request(
|
@@ -341,7 +343,7 @@ module IBMWatson
|
|
341
343
|
end
|
342
344
|
|
343
345
|
##
|
344
|
-
# @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, append: nil)
|
346
|
+
# @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, append: nil)
|
345
347
|
# Update workspace.
|
346
348
|
# Update an existing workspace with new or modified data. You must provide component
|
347
349
|
# objects defining the content of the updated workspace.
|
@@ -362,6 +364,7 @@ module IBMWatson
|
|
362
364
|
# @param metadata [Object] Any metadata related to the workspace.
|
363
365
|
# @param learning_opt_out [Boolean] Whether training data from the workspace can be used by IBM for general service
|
364
366
|
# improvements. `true` indicates that workspace training data is not to be used.
|
367
|
+
# @param system_settings [WorkspaceSystemSettings] Global settings for the workspace.
|
365
368
|
# @param append [Boolean] Whether the new data is to be appended to the existing data in the workspace. If
|
366
369
|
# **append**=`false`, elements included in the new data completely replace the
|
367
370
|
# corresponding existing elements, including all subelements. For example, if the
|
@@ -372,7 +375,7 @@ module IBMWatson
|
|
372
375
|
# added. If any elements in the new data collide with existing elements, the update
|
373
376
|
# request fails.
|
374
377
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
375
|
-
def update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, append: nil)
|
378
|
+
def update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, append: nil)
|
376
379
|
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
377
380
|
headers = {
|
378
381
|
}
|
@@ -389,7 +392,8 @@ module IBMWatson
|
|
389
392
|
"dialog_nodes" => dialog_nodes,
|
390
393
|
"counterexamples" => counterexamples,
|
391
394
|
"metadata" => metadata,
|
392
|
-
"learning_opt_out" => learning_opt_out
|
395
|
+
"learning_opt_out" => learning_opt_out,
|
396
|
+
"system_settings" => system_settings
|
393
397
|
}
|
394
398
|
method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
|
395
399
|
response = request(
|
@@ -635,7 +639,8 @@ module IBMWatson
|
|
635
639
|
##
|
636
640
|
# @!method list_examples(workspace_id:, intent:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
|
637
641
|
# List user input examples.
|
638
|
-
# List the user input examples for an intent
|
642
|
+
# List the user input examples for an intent, optionally including contextual entity
|
643
|
+
# mentions.
|
639
644
|
#
|
640
645
|
# This operation is limited to 2500 requests per 30 minutes. For more information,
|
641
646
|
# see **Rate limiting**.
|
@@ -675,7 +680,7 @@ module IBMWatson
|
|
675
680
|
end
|
676
681
|
|
677
682
|
##
|
678
|
-
# @!method create_example(workspace_id:, intent:, text:)
|
683
|
+
# @!method create_example(workspace_id:, intent:, text:, mentions: nil)
|
679
684
|
# Create user input example.
|
680
685
|
# Add a new user input example to an intent.
|
681
686
|
#
|
@@ -688,8 +693,9 @@ module IBMWatson
|
|
688
693
|
# - It cannot contain carriage return, newline, or tab characters.
|
689
694
|
# - It cannot consist of only whitespace characters.
|
690
695
|
# - It must be no longer than 1024 characters.
|
696
|
+
# @param mentions [Array[Mentions]] An array of contextual entity mentions.
|
691
697
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
692
|
-
def create_example(workspace_id:, intent:, text:)
|
698
|
+
def create_example(workspace_id:, intent:, text:, mentions: nil)
|
693
699
|
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
694
700
|
raise ArgumentError("intent must be provided") if intent.nil?
|
695
701
|
raise ArgumentError("text must be provided") if text.nil?
|
@@ -699,7 +705,8 @@ module IBMWatson
|
|
699
705
|
"version" => @version
|
700
706
|
}
|
701
707
|
data = {
|
702
|
-
"text" => text
|
708
|
+
"text" => text,
|
709
|
+
"mentions" => mentions
|
703
710
|
}
|
704
711
|
method_url = "/v1/workspaces/%s/intents/%s/examples" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
|
705
712
|
response = request(
|
@@ -748,7 +755,7 @@ module IBMWatson
|
|
748
755
|
end
|
749
756
|
|
750
757
|
##
|
751
|
-
# @!method update_example(workspace_id:, intent:, text:, new_text: nil)
|
758
|
+
# @!method update_example(workspace_id:, intent:, text:, new_text: nil, new_mentions: nil)
|
752
759
|
# Update user input example.
|
753
760
|
# Update the text of a user input example.
|
754
761
|
#
|
@@ -762,8 +769,9 @@ module IBMWatson
|
|
762
769
|
# - It cannot contain carriage return, newline, or tab characters.
|
763
770
|
# - It cannot consist of only whitespace characters.
|
764
771
|
# - It must be no longer than 1024 characters.
|
772
|
+
# @param new_mentions [Array[Mentions]] An array of contextual entity mentions.
|
765
773
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
766
|
-
def update_example(workspace_id:, intent:, text:, new_text: nil)
|
774
|
+
def update_example(workspace_id:, intent:, text:, new_text: nil, new_mentions: nil)
|
767
775
|
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
768
776
|
raise ArgumentError("intent must be provided") if intent.nil?
|
769
777
|
raise ArgumentError("text must be provided") if text.nil?
|
@@ -773,7 +781,8 @@ module IBMWatson
|
|
773
781
|
"version" => @version
|
774
782
|
}
|
775
783
|
data = {
|
776
|
-
"text" => new_text
|
784
|
+
"text" => new_text,
|
785
|
+
"mentions" => new_mentions
|
777
786
|
}
|
778
787
|
method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
|
779
788
|
response = request(
|
@@ -1204,6 +1213,46 @@ module IBMWatson
|
|
1204
1213
|
nil
|
1205
1214
|
end
|
1206
1215
|
#########################
|
1216
|
+
# Mentions
|
1217
|
+
#########################
|
1218
|
+
|
1219
|
+
##
|
1220
|
+
# @!method list_mentions(workspace_id:, entity:, export: nil, include_audit: nil)
|
1221
|
+
# List entity mentions.
|
1222
|
+
# List mentions for a contextual entity. An entity mention is an occurrence of a
|
1223
|
+
# contextual entity in the context of an intent user input example.
|
1224
|
+
#
|
1225
|
+
# This operation is limited to 200 requests per 30 minutes. For more information,
|
1226
|
+
# see **Rate limiting**.
|
1227
|
+
# @param workspace_id [String] Unique identifier of the workspace.
|
1228
|
+
# @param entity [String] The name of the entity.
|
1229
|
+
# @param export [Boolean] Whether to include all element content in the returned data. If
|
1230
|
+
# **export**=`false`, the returned data includes only information about the element
|
1231
|
+
# itself. If **export**=`true`, all content, including subelements, is included.
|
1232
|
+
# @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
|
1233
|
+
# the response.
|
1234
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1235
|
+
def list_mentions(workspace_id:, entity:, export: nil, include_audit: nil)
|
1236
|
+
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
1237
|
+
raise ArgumentError("entity must be provided") if entity.nil?
|
1238
|
+
headers = {
|
1239
|
+
}
|
1240
|
+
params = {
|
1241
|
+
"version" => @version,
|
1242
|
+
"export" => export,
|
1243
|
+
"include_audit" => include_audit
|
1244
|
+
}
|
1245
|
+
method_url = "/v1/workspaces/%s/entities/%s/mentions" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
|
1246
|
+
response = request(
|
1247
|
+
method: "GET",
|
1248
|
+
url: method_url,
|
1249
|
+
headers: headers,
|
1250
|
+
params: params,
|
1251
|
+
accept_json: true
|
1252
|
+
)
|
1253
|
+
response
|
1254
|
+
end
|
1255
|
+
#########################
|
1207
1256
|
# Values
|
1208
1257
|
#########################
|
1209
1258
|
|
@@ -1677,7 +1726,7 @@ module IBMWatson
|
|
1677
1726
|
end
|
1678
1727
|
|
1679
1728
|
##
|
1680
|
-
# @!method create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil)
|
1729
|
+
# @!method create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
|
1681
1730
|
# Create dialog node.
|
1682
1731
|
# Create a new dialog node.
|
1683
1732
|
#
|
@@ -1695,7 +1744,7 @@ module IBMWatson
|
|
1695
1744
|
# characters.
|
1696
1745
|
# @param parent [String] The ID of the parent dialog node.
|
1697
1746
|
# @param previous_sibling [String] The ID of the previous dialog node.
|
1698
|
-
# @param output [
|
1747
|
+
# @param output [DialogNodeOutput] The output of the dialog node. For more information about how to specify dialog
|
1699
1748
|
# node output, see the
|
1700
1749
|
# [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex).
|
1701
1750
|
# @param context [Object] The context for the dialog node.
|
@@ -1713,8 +1762,10 @@ module IBMWatson
|
|
1713
1762
|
# @param digress_in [String] Whether this top-level dialog node can be digressed into.
|
1714
1763
|
# @param digress_out [String] Whether this dialog node can be returned to after a digression.
|
1715
1764
|
# @param digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
|
1765
|
+
# @param user_label [String] A label that can be displayed externally to describe the purpose of the node to
|
1766
|
+
# users.
|
1716
1767
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1717
|
-
def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil)
|
1768
|
+
def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
|
1718
1769
|
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
1719
1770
|
raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
|
1720
1771
|
headers = {
|
@@ -1739,7 +1790,8 @@ module IBMWatson
|
|
1739
1790
|
"variable" => variable,
|
1740
1791
|
"digress_in" => digress_in,
|
1741
1792
|
"digress_out" => digress_out,
|
1742
|
-
"digress_out_slots" => digress_out_slots
|
1793
|
+
"digress_out_slots" => digress_out_slots,
|
1794
|
+
"user_label" => user_label
|
1743
1795
|
}
|
1744
1796
|
method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
|
1745
1797
|
response = request(
|
@@ -1786,7 +1838,7 @@ module IBMWatson
|
|
1786
1838
|
end
|
1787
1839
|
|
1788
1840
|
##
|
1789
|
-
# @!method update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil)
|
1841
|
+
# @!method update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil)
|
1790
1842
|
# Update dialog node.
|
1791
1843
|
# Update an existing dialog node with new or modified data.
|
1792
1844
|
#
|
@@ -1805,7 +1857,7 @@ module IBMWatson
|
|
1805
1857
|
# characters.
|
1806
1858
|
# @param new_parent [String] The ID of the parent dialog node.
|
1807
1859
|
# @param new_previous_sibling [String] The ID of the previous sibling dialog node.
|
1808
|
-
# @param new_output [
|
1860
|
+
# @param new_output [DialogNodeOutput] The output of the dialog node. For more information about how to specify dialog
|
1809
1861
|
# node output, see the
|
1810
1862
|
# [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex).
|
1811
1863
|
# @param new_context [Object] The context for the dialog node.
|
@@ -1823,8 +1875,10 @@ module IBMWatson
|
|
1823
1875
|
# @param new_digress_in [String] Whether this top-level dialog node can be digressed into.
|
1824
1876
|
# @param new_digress_out [String] Whether this dialog node can be returned to after a digression.
|
1825
1877
|
# @param new_digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
|
1878
|
+
# @param new_user_label [String] A label that can be displayed externally to describe the purpose of the node to
|
1879
|
+
# users.
|
1826
1880
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1827
|
-
def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil)
|
1881
|
+
def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil, new_user_label: nil)
|
1828
1882
|
raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
|
1829
1883
|
raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
|
1830
1884
|
headers = {
|
@@ -1849,7 +1903,8 @@ module IBMWatson
|
|
1849
1903
|
"actions" => new_actions,
|
1850
1904
|
"digress_in" => new_digress_in,
|
1851
1905
|
"digress_out" => new_digress_out,
|
1852
|
-
"digress_out_slots" => new_digress_out_slots
|
1906
|
+
"digress_out_slots" => new_digress_out_slots,
|
1907
|
+
"user_label" => new_user_label
|
1853
1908
|
}
|
1854
1909
|
method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
|
1855
1910
|
response = request(
|
@@ -1072,7 +1072,7 @@ module IBMWatson
|
|
1072
1072
|
#########################
|
1073
1073
|
|
1074
1074
|
##
|
1075
|
-
# @!method query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
|
1075
|
+
# @!method query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, logging_opt_out: nil)
|
1076
1076
|
# Query your collection.
|
1077
1077
|
# After your content is uploaded and enriched by the Discovery service, you can
|
1078
1078
|
# build queries to search your content. For details, see the [Discovery service
|
@@ -1130,11 +1130,13 @@ module IBMWatson
|
|
1130
1130
|
# @param similar_fields [Array[String]] A comma-separated list of field names that will be used as a basis for comparison
|
1131
1131
|
# to identify similar documents. If not specified, the entire document is used for
|
1132
1132
|
# comparison.
|
1133
|
+
# @param logging_opt_out [Boolean] If `true`, queries are not stored in the Discovery **Logs** endpoint.
|
1133
1134
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1134
|
-
def query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil)
|
1135
|
+
def query(environment_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, passages: nil, aggregation: nil, count: nil, return_fields: nil, offset: nil, sort: nil, highlight: nil, passages_fields: nil, passages_count: nil, passages_characters: nil, deduplicate: nil, deduplicate_field: nil, similar: nil, similar_document_ids: nil, similar_fields: nil, logging_opt_out: nil)
|
1135
1136
|
raise ArgumentError("environment_id must be provided") if environment_id.nil?
|
1136
1137
|
raise ArgumentError("collection_id must be provided") if collection_id.nil?
|
1137
1138
|
headers = {
|
1139
|
+
"X-Watson-Logging-Opt-Out" => logging_opt_out
|
1138
1140
|
}
|
1139
1141
|
params = {
|
1140
1142
|
"version" => @version,
|
@@ -349,35 +349,36 @@ module IBMWatson
|
|
349
349
|
# useful for stopping audio submission from a live microphone when a user simply
|
350
350
|
# walks away. Use `-1` for infinity.
|
351
351
|
# @param keywords [Array[String]] An array of keyword strings to spot in the audio. Each keyword string can include
|
352
|
-
# one or more tokens. Keywords are spotted only in the final results, not in
|
353
|
-
# hypotheses. If you specify any keywords, you must also specify a keywords
|
352
|
+
# one or more string tokens. Keywords are spotted only in the final results, not in
|
353
|
+
# interim hypotheses. If you specify any keywords, you must also specify a keywords
|
354
354
|
# threshold. You can spot a maximum of 1000 keywords. Omit the parameter or specify
|
355
355
|
# an empty array if you do not need to spot keywords.
|
356
356
|
# @param keywords_threshold [Float] A confidence value that is the lower bound for spotting a keyword. A word is
|
357
357
|
# considered to match a keyword if its confidence is greater than or equal to the
|
358
|
-
# threshold. Specify a probability between 0 and 1
|
358
|
+
# threshold. Specify a probability between 0.0 and 1.0. No keyword spotting is
|
359
359
|
# performed if you omit the parameter. If you specify a threshold, you must also
|
360
360
|
# specify one or more keywords.
|
361
|
-
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts
|
362
|
-
# transcription is returned.
|
361
|
+
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts that the service is to return. By
|
362
|
+
# default, a single transcription is returned.
|
363
363
|
# @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
|
364
364
|
# possible word alternative (also known as \"Confusion Networks\"). An alternative
|
365
365
|
# word is considered if its confidence is greater than or equal to the threshold.
|
366
|
-
# Specify a probability between 0 and 1
|
367
|
-
#
|
368
|
-
# @param word_confidence [Boolean] If `true`, a confidence measure in the range of 0 to 1
|
369
|
-
# By default, no word confidence measures are returned.
|
370
|
-
# @param timestamps [Boolean] If `true`, time alignment
|
371
|
-
# returned.
|
372
|
-
# @param profanity_filter [Boolean] If `true
|
366
|
+
# Specify a probability between 0.0 and 1.0. No alternative words are computed if
|
367
|
+
# you omit the parameter.
|
368
|
+
# @param word_confidence [Boolean] If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for
|
369
|
+
# each word. By default, no word confidence measures are returned.
|
370
|
+
# @param timestamps [Boolean] If `true`, the service returns time alignment for each word. By default, no
|
371
|
+
# timestamps are returned.
|
372
|
+
# @param profanity_filter [Boolean] If `true`, the service filters profanity from all output except for keyword
|
373
373
|
# results by replacing inappropriate words with a series of asterisks. Set the
|
374
374
|
# parameter to `false` to return results with no censoring. Applies to US English
|
375
375
|
# transcription only.
|
376
|
-
# @param smart_formatting [Boolean] If `true`, converts dates, times, series of digits and numbers, phone
|
377
|
-
# currency values, and internet addresses into more readable, conventional
|
376
|
+
# @param smart_formatting [Boolean] If `true`, the service converts dates, times, series of digits and numbers, phone
|
377
|
+
# numbers, currency values, and internet addresses into more readable, conventional
|
378
378
|
# representations in the final transcript of a recognition request. For US English,
|
379
|
-
# also converts certain keyword strings to punctuation symbols. By
|
380
|
-
# formatting is performed. Applies to US English and Spanish
|
379
|
+
# the service also converts certain keyword strings to punctuation symbols. By
|
380
|
+
# default, no smart formatting is performed. Applies to US English and Spanish
|
381
|
+
# transcription only.
|
381
382
|
# @param speaker_labels [Boolean] If `true`, the response includes labels that identify which words were spoken by
|
382
383
|
# which participants in a multi-person exchange. By default, no speaker labels are
|
383
384
|
# returned. Setting `speaker_labels` to `true` forces the `timestamps` parameter to
|
@@ -425,7 +426,7 @@ module IBMWatson
|
|
425
426
|
end
|
426
427
|
|
427
428
|
##
|
428
|
-
# @!method
|
429
|
+
# @!method recognize_using_websocket(audio: nil,chunk_data: false,content_type: "audio/l16; rate=44100",model: "en-US_BroadbandModel",recognize_callback: nil,customization_id: nil,acoustic_customization_id: nil,customization_weight: nil,version: nil,inactivity_timeout: 30,interim_results: false,keywords: nil,keywords_threshold: nil,max_alternatives: 1,word_alternatives_threshold: nil,word_confidence: false,timestamps: false,profanity_filter: nil,smart_formatting: false,speaker_labels: nil)
|
429
430
|
# Sends audio for speech recognition using web sockets.
|
430
431
|
# @param audio [IO] Audio to transcribe in the format specified by the `Content-Type` header.
|
431
432
|
# @param chunk_data [Boolean] If true, then the WebSocketClient will expect to receive data in chunks rather than as a single audio file
|
@@ -448,7 +449,7 @@ module IBMWatson
|
|
448
449
|
# @param smart_formatting [Boolean] If `true`, converts dates, times, series of digits and numbers, phone numbers, currency values, and Internet addresses into more readable, conventional representations in the final transcript of a recognition request. If `false` (the default), no formatting is performed. Applies to US English transcription only.
|
449
450
|
# @param speaker_labels [Boolean] Indicates whether labels that identify which words were spoken by which participants in a multi-person exchange are to be included in the response. The default is `false`; no speaker labels are returned. Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. To determine whether a language model supports speaker labels, use the `GET /v1/models` method and check that the attribute `speaker_labels` is set to `true`. You can also refer to [Speaker labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
|
450
451
|
# @return [WebSocketClient] Returns a new WebSocketClient object
|
451
|
-
def
|
452
|
+
def recognize_using_websocket(
|
452
453
|
audio: nil,
|
453
454
|
chunk_data: false,
|
454
455
|
content_type: "audio/l16; rate=44100",
|
@@ -509,6 +510,56 @@ module IBMWatson
|
|
509
510
|
options.delete_if { |_, v| v.nil? }
|
510
511
|
WebSocketClient.new(audio: audio, chunk_data: chunk_data, options: options, recognize_callback: recognize_callback, url: url, headers: headers)
|
511
512
|
end
|
513
|
+
|
514
|
+
# :nocov:
|
515
|
+
# @deprecated This will method be removed in the next major release. Use {#recognize_using_websocket} instead.
|
516
|
+
def recognize_with_websocket(
|
517
|
+
audio: nil,
|
518
|
+
chunk_data: false,
|
519
|
+
content_type: "audio/l16; rate=44100",
|
520
|
+
model: "en-US_BroadbandModel",
|
521
|
+
recognize_callback: nil,
|
522
|
+
customization_id: nil,
|
523
|
+
acoustic_customization_id: nil,
|
524
|
+
customization_weight: nil,
|
525
|
+
version: nil,
|
526
|
+
inactivity_timeout: 30,
|
527
|
+
interim_results: false,
|
528
|
+
keywords: nil,
|
529
|
+
keywords_threshold: nil,
|
530
|
+
max_alternatives: 1,
|
531
|
+
word_alternatives_threshold: nil,
|
532
|
+
word_confidence: false,
|
533
|
+
timestamps: false,
|
534
|
+
profanity_filter: nil,
|
535
|
+
smart_formatting: false,
|
536
|
+
speaker_labels: nil
|
537
|
+
)
|
538
|
+
Kernel.warn("[DEPRECATION] `recognize_with_websocket` is deprecated and will be removed in the next major release. Please use `recognize_using_websocket` instead.")
|
539
|
+
recognize_using_websocket(
|
540
|
+
audio: audio,
|
541
|
+
chunk_data: chunk_data,
|
542
|
+
content_type: content_type,
|
543
|
+
model: model,
|
544
|
+
recognize_callback: recognize_callback,
|
545
|
+
customization_id: customization_id,
|
546
|
+
acoustic_customization_id: acoustic_customization_id,
|
547
|
+
customization_weight: customization_weight,
|
548
|
+
version: version,
|
549
|
+
inactivity_timeout: inactivity_timeout,
|
550
|
+
interim_results: interim_results,
|
551
|
+
keywords: keywords,
|
552
|
+
keywords_threshold: keywords_threshold,
|
553
|
+
max_alternatives: max_alternatives,
|
554
|
+
word_alternatives_threshold: word_alternatives_threshold,
|
555
|
+
word_confidence: word_confidence,
|
556
|
+
timestamps: timestamps,
|
557
|
+
profanity_filter: profanity_filter,
|
558
|
+
smart_formatting: smart_formatting,
|
559
|
+
speaker_labels: speaker_labels
|
560
|
+
)
|
561
|
+
end
|
562
|
+
# :nocov:
|
512
563
|
#########################
|
513
564
|
# Asynchronous
|
514
565
|
#########################
|
@@ -744,35 +795,36 @@ module IBMWatson
|
|
744
795
|
# useful for stopping audio submission from a live microphone when a user simply
|
745
796
|
# walks away. Use `-1` for infinity.
|
746
797
|
# @param keywords [Array[String]] An array of keyword strings to spot in the audio. Each keyword string can include
|
747
|
-
# one or more tokens. Keywords are spotted only in the final results, not in
|
748
|
-
# hypotheses. If you specify any keywords, you must also specify a keywords
|
798
|
+
# one or more string tokens. Keywords are spotted only in the final results, not in
|
799
|
+
# interim hypotheses. If you specify any keywords, you must also specify a keywords
|
749
800
|
# threshold. You can spot a maximum of 1000 keywords. Omit the parameter or specify
|
750
801
|
# an empty array if you do not need to spot keywords.
|
751
802
|
# @param keywords_threshold [Float] A confidence value that is the lower bound for spotting a keyword. A word is
|
752
803
|
# considered to match a keyword if its confidence is greater than or equal to the
|
753
|
-
# threshold. Specify a probability between 0 and 1
|
804
|
+
# threshold. Specify a probability between 0.0 and 1.0. No keyword spotting is
|
754
805
|
# performed if you omit the parameter. If you specify a threshold, you must also
|
755
806
|
# specify one or more keywords.
|
756
|
-
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts
|
757
|
-
# transcription is returned.
|
807
|
+
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts that the service is to return. By
|
808
|
+
# default, a single transcription is returned.
|
758
809
|
# @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
|
759
810
|
# possible word alternative (also known as \"Confusion Networks\"). An alternative
|
760
811
|
# word is considered if its confidence is greater than or equal to the threshold.
|
761
|
-
# Specify a probability between 0 and 1
|
762
|
-
#
|
763
|
-
# @param word_confidence [Boolean] If `true`, a confidence measure in the range of 0 to 1
|
764
|
-
# By default, no word confidence measures are returned.
|
765
|
-
# @param timestamps [Boolean] If `true`, time alignment
|
766
|
-
# returned.
|
767
|
-
# @param profanity_filter [Boolean] If `true
|
812
|
+
# Specify a probability between 0.0 and 1.0. No alternative words are computed if
|
813
|
+
# you omit the parameter.
|
814
|
+
# @param word_confidence [Boolean] If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 for
|
815
|
+
# each word. By default, no word confidence measures are returned.
|
816
|
+
# @param timestamps [Boolean] If `true`, the service returns time alignment for each word. By default, no
|
817
|
+
# timestamps are returned.
|
818
|
+
# @param profanity_filter [Boolean] If `true`, the service filters profanity from all output except for keyword
|
768
819
|
# results by replacing inappropriate words with a series of asterisks. Set the
|
769
820
|
# parameter to `false` to return results with no censoring. Applies to US English
|
770
821
|
# transcription only.
|
771
|
-
# @param smart_formatting [Boolean] If `true`, converts dates, times, series of digits and numbers, phone
|
772
|
-
# currency values, and internet addresses into more readable, conventional
|
822
|
+
# @param smart_formatting [Boolean] If `true`, the service converts dates, times, series of digits and numbers, phone
|
823
|
+
# numbers, currency values, and internet addresses into more readable, conventional
|
773
824
|
# representations in the final transcript of a recognition request. For US English,
|
774
|
-
# also converts certain keyword strings to punctuation symbols. By
|
775
|
-
# formatting is performed. Applies to US English and Spanish
|
825
|
+
# the service also converts certain keyword strings to punctuation symbols. By
|
826
|
+
# default, no smart formatting is performed. Applies to US English and Spanish
|
827
|
+
# transcription only.
|
776
828
|
# @param speaker_labels [Boolean] If `true`, the response includes labels that identify which words were spoken by
|
777
829
|
# which participants in a multi-person exchange. By default, no speaker labels are
|
778
830
|
# returned. Setting `speaker_labels` to `true` forces the `timestamps` parameter to
|
@@ -1257,9 +1309,9 @@ module IBMWatson
|
|
1257
1309
|
# if it encounters non-ASCII characters. With cURL, use the `--data-binary` option
|
1258
1310
|
# to upload the file for the request.
|
1259
1311
|
# @param allow_overwrite [Boolean] If `true`, the specified corpus or audio resource overwrites an existing corpus or
|
1260
|
-
# audio resource with the same name. If `false
|
1261
|
-
#
|
1262
|
-
#
|
1312
|
+
# audio resource with the same name. If `false`, the request fails if a corpus or
|
1313
|
+
# audio resource with the same name already exists. The parameter has no effect if a
|
1314
|
+
# corpus or audio resource with the same name does not already exist.
|
1263
1315
|
# @param corpus_filename [String] The filename for corpus_file.
|
1264
1316
|
# @return [nil]
|
1265
1317
|
def add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil, corpus_filename: nil)
|
@@ -2021,9 +2073,9 @@ module IBMWatson
|
|
2021
2073
|
# parameters that are used with some formats. For a complete list of supported audio
|
2022
2074
|
# formats, see [Audio formats](/docs/services/speech-to-text/input.html#formats).
|
2023
2075
|
# @param allow_overwrite [Boolean] If `true`, the specified corpus or audio resource overwrites an existing corpus or
|
2024
|
-
# audio resource with the same name. If `false
|
2025
|
-
#
|
2026
|
-
#
|
2076
|
+
# audio resource with the same name. If `false`, the request fails if a corpus or
|
2077
|
+
# audio resource with the same name already exists. The parameter has no effect if a
|
2078
|
+
# corpus or audio resource with the same name does not already exist.
|
2027
2079
|
# @return [nil]
|
2028
2080
|
def add_audio(customization_id:, audio_name:, audio_resource:, content_type:, contained_content_type: nil, allow_overwrite: nil)
|
2029
2081
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
data/lib/ibm_watson/version.rb
CHANGED
@@ -131,7 +131,7 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
131
131
|
def test_recognize_websocket_as_chunks
|
132
132
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
133
133
|
mycallback = MyRecognizeCallback.new
|
134
|
-
speech = @service.
|
134
|
+
speech = @service.recognize_using_websocket(
|
135
135
|
chunk_data: true,
|
136
136
|
recognize_callback: mycallback,
|
137
137
|
interim_results: true,
|
@@ -155,7 +155,7 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
155
155
|
def test_recognize_websocket
|
156
156
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
157
157
|
mycallback = MyRecognizeCallback.new
|
158
|
-
speech = @service.
|
158
|
+
speech = @service.recognize_using_websocket(
|
159
159
|
audio: audio_file,
|
160
160
|
recognize_callback: mycallback,
|
161
161
|
interim_results: true,
|
@@ -168,11 +168,11 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
168
168
|
thr.join
|
169
169
|
end
|
170
170
|
|
171
|
-
def
|
171
|
+
def test_inactivity_timeout_using_websocket
|
172
172
|
audio_file = File.open(Dir.getwd + "/resources/sound-with-pause.wav")
|
173
173
|
atomic_boolean = Concurrent::AtomicBoolean.new
|
174
174
|
mycallback = MyRecognizeCallback.new(atomic_boolean: atomic_boolean)
|
175
|
-
speech = @service.
|
175
|
+
speech = @service.recognize_using_websocket(
|
176
176
|
audio: audio_file,
|
177
177
|
recognize_callback: mycallback,
|
178
178
|
interim_results: true,
|
@@ -187,11 +187,11 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
187
187
|
assert(atomic_boolean.true?)
|
188
188
|
end
|
189
189
|
|
190
|
-
def
|
190
|
+
def test_broken_audio_using_websocket
|
191
191
|
audio_file = File.open(Dir.getwd + "/resources/car.jpg")
|
192
192
|
atomic_boolean = Concurrent::AtomicBoolean.new
|
193
193
|
mycallback = MyRecognizeCallback.new(atomic_boolean: atomic_boolean)
|
194
|
-
speech = @service.
|
194
|
+
speech = @service.recognize_using_websocket(
|
195
195
|
audio: audio_file,
|
196
196
|
recognize_callback: mycallback,
|
197
197
|
interim_results: true,
|
@@ -205,7 +205,7 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
205
205
|
assert(atomic_boolean.true?)
|
206
206
|
end
|
207
207
|
|
208
|
-
def
|
208
|
+
def test_invalid_auth_using_websocket
|
209
209
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
210
210
|
atomic_boolean = Concurrent::AtomicBoolean.new
|
211
211
|
mycallback = MyRecognizeCallback.new(atomic_boolean: atomic_boolean)
|
@@ -218,7 +218,7 @@ unless ENV["SPEECH_TO_TEXT_USERNAME"].nil? || ENV["SPEECH_TO_TEXT_PASSWORD"].nil
|
|
218
218
|
"X-Watson-Test" => "1"
|
219
219
|
}
|
220
220
|
)
|
221
|
-
speech = temp_service.
|
221
|
+
speech = temp_service.recognize_using_websocket(
|
222
222
|
audio: audio_file,
|
223
223
|
recognize_callback: mycallback,
|
224
224
|
interim_results: true,
|
@@ -425,7 +425,7 @@ class AssistantV1Test < Minitest::Test
|
|
425
425
|
}
|
426
426
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples?version=2018-02-16")
|
427
427
|
.with(
|
428
|
-
body: "{\"text\":\"Gimme a pizza with pepperoni\"}",
|
428
|
+
body: "{\"text\":\"Gimme a pizza with pepperoni\",\"mentions\":[{\"mentioned\":\"yes\"}]}",
|
429
429
|
headers: {
|
430
430
|
"Accept" => "application/json",
|
431
431
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -441,7 +441,8 @@ class AssistantV1Test < Minitest::Test
|
|
441
441
|
service_response = service.create_example(
|
442
442
|
workspace_id: "boguswid",
|
443
443
|
intent: "pizza_order",
|
444
|
-
text: "Gimme a pizza with pepperoni"
|
444
|
+
text: "Gimme a pizza with pepperoni",
|
445
|
+
mentions: [{ "mentioned" => "yes" }]
|
445
446
|
)
|
446
447
|
assert_equal(response, service_response.result)
|
447
448
|
end
|
@@ -553,7 +554,7 @@ class AssistantV1Test < Minitest::Test
|
|
553
554
|
}
|
554
555
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/boguswid/intents/pizza_order/examples/Gimme%20a%20pizza%20with%20pepperoni?version=2018-02-16")
|
555
556
|
.with(
|
556
|
-
body: "{\"text\":\"Gimme a pizza with pepperoni\"}",
|
557
|
+
body: "{\"text\":\"Gimme a pizza with pepperoni\",\"mentions\":[{\"mentioned\":\"yes\"}]}",
|
557
558
|
headers: {
|
558
559
|
"Accept" => "application/json",
|
559
560
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -570,7 +571,8 @@ class AssistantV1Test < Minitest::Test
|
|
570
571
|
workspace_id: "boguswid",
|
571
572
|
intent: "pizza_order",
|
572
573
|
text: "Gimme a pizza with pepperoni",
|
573
|
-
new_text: "Gimme a pizza with pepperoni"
|
574
|
+
new_text: "Gimme a pizza with pepperoni",
|
575
|
+
new_mentions: [{ "mentioned" => "yes" }]
|
574
576
|
)
|
575
577
|
assert_equal(response, service_response.result)
|
576
578
|
end
|
@@ -1325,7 +1327,7 @@ class AssistantV1Test < Minitest::Test
|
|
1325
1327
|
}
|
1326
1328
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces?version=2018-02-16")
|
1327
1329
|
.with(
|
1328
|
-
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{}}",
|
1330
|
+
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{},\"system_settings\":{\"system_settings\":\"yes\"}}",
|
1329
1331
|
headers: {
|
1330
1332
|
"Accept" => "application/json",
|
1331
1333
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -1342,7 +1344,8 @@ class AssistantV1Test < Minitest::Test
|
|
1342
1344
|
name: "Pizza app",
|
1343
1345
|
description: "Pizza app",
|
1344
1346
|
language: "en",
|
1345
|
-
metadata: {}
|
1347
|
+
metadata: {},
|
1348
|
+
system_settings: { "system_settings" => "yes" }
|
1346
1349
|
)
|
1347
1350
|
assert_equal(response, service_response.result)
|
1348
1351
|
end
|
@@ -1458,7 +1461,7 @@ class AssistantV1Test < Minitest::Test
|
|
1458
1461
|
}
|
1459
1462
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/pizza_app-e0f3?version=2018-02-16")
|
1460
1463
|
.with(
|
1461
|
-
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{}}",
|
1464
|
+
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{},\"system_settings\":{\"system_settings\":\"yes\"}}",
|
1462
1465
|
headers: {
|
1463
1466
|
"Accept" => "application/json",
|
1464
1467
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -1476,7 +1479,8 @@ class AssistantV1Test < Minitest::Test
|
|
1476
1479
|
name: "Pizza app",
|
1477
1480
|
description: "Pizza app",
|
1478
1481
|
language: "en",
|
1479
|
-
metadata: {}
|
1482
|
+
metadata: {},
|
1483
|
+
system_settings: { "system_settings" => "yes" }
|
1480
1484
|
)
|
1481
1485
|
assert_equal(response, service_response.result)
|
1482
1486
|
end
|
@@ -1493,7 +1497,7 @@ class AssistantV1Test < Minitest::Test
|
|
1493
1497
|
|
1494
1498
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/id/dialog_nodes?version=2018-02-16")
|
1495
1499
|
.with(
|
1496
|
-
body: "{\"dialog_node\":\"location-done\"}",
|
1500
|
+
body: "{\"dialog_node\":\"location-done\",\"user_label\":\"labeled\"}",
|
1497
1501
|
headers: {
|
1498
1502
|
"Accept" => "application/json",
|
1499
1503
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -1503,7 +1507,8 @@ class AssistantV1Test < Minitest::Test
|
|
1503
1507
|
).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-done" } }.to_json, headers: headers)
|
1504
1508
|
service_response = service.create_dialog_node(
|
1505
1509
|
workspace_id: "id",
|
1506
|
-
dialog_node: "location-done"
|
1510
|
+
dialog_node: "location-done",
|
1511
|
+
user_label: "labeled"
|
1507
1512
|
)
|
1508
1513
|
assert_equal("location-done", service_response.result["application/json"]["dialog_node"])
|
1509
1514
|
|
@@ -1580,7 +1585,7 @@ class AssistantV1Test < Minitest::Test
|
|
1580
1585
|
)
|
1581
1586
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspace_id/dialog_nodes/dialog_node?version=2018-02-16")
|
1582
1587
|
.with(
|
1583
|
-
body: "{\"description\":\"A new description\"}",
|
1588
|
+
body: "{\"description\":\"A new description\",\"user_label\":\"new_label\"}",
|
1584
1589
|
headers: {
|
1585
1590
|
"Accept" => "application/json",
|
1586
1591
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
@@ -1591,8 +1596,32 @@ class AssistantV1Test < Minitest::Test
|
|
1591
1596
|
service_response = service.update_dialog_node(
|
1592
1597
|
workspace_id: "workspace_id",
|
1593
1598
|
dialog_node: "dialog_node",
|
1594
|
-
new_description: "A new description"
|
1599
|
+
new_description: "A new description",
|
1600
|
+
new_user_label: "new_label"
|
1595
1601
|
)
|
1596
1602
|
assert_equal("Pseudo update dialog node response", service_response.result)
|
1597
1603
|
end
|
1604
|
+
|
1605
|
+
def test_list_mentions
|
1606
|
+
service = IBMWatson::AssistantV1.new(
|
1607
|
+
username: "username",
|
1608
|
+
password: "password",
|
1609
|
+
version: "2018-02-16"
|
1610
|
+
)
|
1611
|
+
stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspace_id/entities/entity/mentions?export=true&include_audit=true&version=2018-02-16")
|
1612
|
+
.with(
|
1613
|
+
headers: {
|
1614
|
+
"Accept" => "application/json",
|
1615
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1616
|
+
"Host" => "gateway.watsonplatform.net"
|
1617
|
+
}
|
1618
|
+
).to_return(status: 200, body: { "list_mentions_response" => "yes" }.to_json, headers: { "Content-Type" => "application/json" })
|
1619
|
+
service_response = service.list_mentions(
|
1620
|
+
workspace_id: "workspace_id",
|
1621
|
+
entity: "entity",
|
1622
|
+
export: true,
|
1623
|
+
include_audit: true
|
1624
|
+
)
|
1625
|
+
assert_equal({ "list_mentions_response" => "yes" }, service_response.result)
|
1626
|
+
end
|
1598
1627
|
end
|
@@ -259,13 +259,15 @@ class DiscoveryV1Test < Minitest::Test
|
|
259
259
|
headers: {
|
260
260
|
"Accept" => "application/json",
|
261
261
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
262
|
-
"Host" => "gateway.watsonplatform.net"
|
262
|
+
"Host" => "gateway.watsonplatform.net",
|
263
|
+
"X-Watson-Logging-Opt-Out" => true
|
263
264
|
}
|
264
265
|
).to_return(status: 200, body: { body: "hello" }.to_json, headers: { "Content-Type" => "application/json" })
|
265
266
|
service_response = service.query(
|
266
267
|
environment_id: "envid",
|
267
268
|
collection_id: "collid",
|
268
|
-
count: 10
|
269
|
+
count: 10,
|
270
|
+
logging_opt_out: true
|
269
271
|
)
|
270
272
|
assert_equal({ "body" => "hello" }, service_response.result)
|
271
273
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibm_watson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Nussbaum
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|