ibm_watson 0.10.0 → 0.11.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 +17 -2
- data/lib/ibm_watson/assistant_v1.rb +7 -7
- data/lib/ibm_watson/discovery_v1.rb +206 -1
- data/lib/ibm_watson/speech_to_text_v1.rb +619 -276
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +8 -11
- data/lib/ibm_watson/watson_service.rb +19 -2
- data/test/integration/test_discovery_v1.rb +27 -1
- data/test/integration/test_speech_to_text_v1.rb +1 -0
- data/test/unit/test_configure_http_client.rb +10 -0
- data/test/unit/test_discovery_v1.rb +124 -0
- data/test/unit/test_speech_to_text_v1.rb +81 -0
- data/test/unit/test_watson_service.rb +44 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77be503c0c2580751176c1ffaae4f1bf60b44c7941580800f14d6a5313e40437
|
4
|
+
data.tar.gz: 6ce107373c372c8ff4f275dd62f402878dc440bf624706d8177a4620f92698f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db32ad31b000f454618880bcc0237d75e9980dcfb7c394645fae954e12fdd3919a2e22c2623911c8f28d272b5791b35503fdc596627579698bbdef9591c6b08
|
7
|
+
data.tar.gz: 76cf957d401eff267742da48026ed16ab592a5b37573cd8a487183f14a94f8e7e377bacd68e5e460f3e87c461cde4595b2f97fc35ec73e1df1d1a1e7629e0beb
|
data/README.md
CHANGED
@@ -35,8 +35,6 @@ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
|
|
35
35
|
## Before you begin
|
36
36
|
* You need an [IBM Cloud][ibm-cloud-onboarding] account.
|
37
37
|
|
38
|
-
> Watson Assistant v2 API is released in beta. For details, see the ["Introducing Watson Assistant"](https://www.ibm.com/blogs/watson/2018/03/the-future-of-watson-conversation-watson-assistant/) blog post.
|
39
|
-
|
40
38
|
## Installation
|
41
39
|
|
42
40
|
Install the gem:
|
@@ -250,6 +248,23 @@ assistant.configure_http_client(
|
|
250
248
|
)
|
251
249
|
```
|
252
250
|
|
251
|
+
The HTTP client can be configured to disable SSL verification. Note that this has serious security implications - only do this if you really mean to! ⚠️
|
252
|
+
|
253
|
+
To do this, pass `disable_ssl` as `true` in `configure_http_client()`, like below:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
require "ibm_watson/assistant_v1"
|
257
|
+
include IBMWatson
|
258
|
+
|
259
|
+
service = AssistantV1.new(
|
260
|
+
version: "<version>",
|
261
|
+
username: "<username>",
|
262
|
+
password: "<password>",
|
263
|
+
)
|
264
|
+
|
265
|
+
service.configure_http_client(disable_ssl: true)
|
266
|
+
```
|
267
|
+
|
253
268
|
## Using Websockets
|
254
269
|
|
255
270
|
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:
|
@@ -1398,7 +1398,7 @@ module IBMWatson
|
|
1398
1398
|
# patterns (as indicated by **type**), but not both. A pattern is a regular
|
1399
1399
|
# expression no longer than 512 characters. For more information about how to
|
1400
1400
|
# specify a pattern, see the
|
1401
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
1401
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/entities.html#creating-entities).
|
1402
1402
|
# @param value_type [String] Specifies the type of value.
|
1403
1403
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1404
1404
|
def create_value(workspace_id:, entity:, value:, metadata: nil, synonyms: nil, patterns: nil, value_type: nil)
|
@@ -1508,7 +1508,7 @@ module IBMWatson
|
|
1508
1508
|
# patterns (as indicated by **type**), but not both. A pattern is a regular
|
1509
1509
|
# expression no longer than 512 characters. For more information about how to
|
1510
1510
|
# specify a pattern, see the
|
1511
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
1511
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/entities.html#creating-entities).
|
1512
1512
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1513
1513
|
def update_value(workspace_id:, entity:, value:, new_value: nil, new_metadata: nil, new_type: nil, new_synonyms: nil, new_patterns: nil)
|
1514
1514
|
raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
|
@@ -1881,7 +1881,7 @@ module IBMWatson
|
|
1881
1881
|
# @param previous_sibling [String] The ID of the previous dialog node.
|
1882
1882
|
# @param output [DialogNodeOutput] The output of the dialog node. For more information about how to specify dialog
|
1883
1883
|
# node output, see the
|
1884
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
1884
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/dialog-overview.html#complex).
|
1885
1885
|
# @param context [Object] The context for the dialog node.
|
1886
1886
|
# @param metadata [Object] The metadata for the dialog node.
|
1887
1887
|
# @param next_step [DialogNodeNextStep] The next step to execute following this dialog node.
|
@@ -2005,7 +2005,7 @@ module IBMWatson
|
|
2005
2005
|
# @param new_previous_sibling [String] The ID of the previous sibling dialog node.
|
2006
2006
|
# @param new_output [DialogNodeOutput] The output of the dialog node. For more information about how to specify dialog
|
2007
2007
|
# node output, see the
|
2008
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
2008
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/dialog-overview.html#complex).
|
2009
2009
|
# @param new_context [Object] The context for the dialog node.
|
2010
2010
|
# @param new_metadata [Object] The metadata for the dialog node.
|
2011
2011
|
# @param new_next_step [DialogNodeNextStep] The next step to execute following this dialog node.
|
@@ -2120,7 +2120,7 @@ module IBMWatson
|
|
2120
2120
|
# reverse the sort order, prefix the parameter value with a minus sign (`-`).
|
2121
2121
|
# @param filter [String] A cacheable parameter that limits the results to those matching the specified
|
2122
2122
|
# filter. For more information, see the
|
2123
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
2123
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/filter-reference.html#filter-query-syntax).
|
2124
2124
|
# @param page_limit [Fixnum] The number of records to return in each page of results.
|
2125
2125
|
# @param cursor [String] A token identifying the page of results to retrieve.
|
2126
2126
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
@@ -2162,7 +2162,7 @@ module IBMWatson
|
|
2162
2162
|
# filter. You must specify a filter query that includes a value for `language`, as
|
2163
2163
|
# well as a value for `workspace_id` or `request.context.metadata.deployment`. For
|
2164
2164
|
# more information, see the
|
2165
|
-
# [documentation](https://console.bluemix.net/docs/services/
|
2165
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/filter-reference.html#filter-query-syntax).
|
2166
2166
|
# @param sort [String] How to sort the returned log events. You can sort by **request_timestamp**. To
|
2167
2167
|
# reverse the sort order, prefix the parameter value with a minus sign (`-`).
|
2168
2168
|
# @param page_limit [Fixnum] The number of records to return in each page of results.
|
@@ -2206,7 +2206,7 @@ module IBMWatson
|
|
2206
2206
|
# You associate a customer ID with data by passing the `X-Watson-Metadata` header
|
2207
2207
|
# with a request that passes data. For more information about personal data and
|
2208
2208
|
# customer IDs, see [Information
|
2209
|
-
# security](https://console.bluemix.net/docs/services/
|
2209
|
+
# security](https://console.bluemix.net/docs/services/assistant/information-security.html).
|
2210
2210
|
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
2211
2211
|
# @return [nil]
|
2212
2212
|
def delete_user_data(customer_id:)
|
@@ -785,7 +785,7 @@ module IBMWatson
|
|
785
785
|
response
|
786
786
|
end
|
787
787
|
#########################
|
788
|
-
#
|
788
|
+
# Query modifications
|
789
789
|
#########################
|
790
790
|
|
791
791
|
##
|
@@ -1009,6 +1009,82 @@ module IBMWatson
|
|
1009
1009
|
)
|
1010
1010
|
nil
|
1011
1011
|
end
|
1012
|
+
|
1013
|
+
##
|
1014
|
+
# @!method create_stopword_list(environment_id:, collection_id:, stopword_file:, stopword_filename: nil)
|
1015
|
+
# Create stopword list.
|
1016
|
+
# Upload a custom stopword list to use with the specified collection.
|
1017
|
+
# @param environment_id [String] The ID of the environment.
|
1018
|
+
# @param collection_id [String] The ID of the collection.
|
1019
|
+
# @param stopword_file [File] The content of the stopword list to ingest.
|
1020
|
+
# @param stopword_filename [String] The filename for stopword_file.
|
1021
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1022
|
+
def create_stopword_list(environment_id:, collection_id:, stopword_file:, stopword_filename: nil)
|
1023
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
1024
|
+
|
1025
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
1026
|
+
|
1027
|
+
raise ArgumentError.new("stopword_file must be provided") if stopword_file.nil?
|
1028
|
+
|
1029
|
+
headers = {
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
params = {
|
1033
|
+
"version" => @version
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
form_data = {}
|
1037
|
+
|
1038
|
+
unless stopword_file.instance_of?(StringIO) || stopword_file.instance_of?(File)
|
1039
|
+
stopword_file = stopword_file.respond_to?(:to_json) ? StringIO.new(stopword_file.to_json) : StringIO.new(stopword_file)
|
1040
|
+
end
|
1041
|
+
stopword_filename = stopword_file.path if stopword_filename.nil? && stopword_file.respond_to?(:path)
|
1042
|
+
form_data[:stopword_file] = HTTP::FormData::File.new(stopword_file, content_type: "application/octet-stream", filename: stopword_filename)
|
1043
|
+
|
1044
|
+
method_url = "/v1/environments/%s/collections/%s/word_lists/stopwords" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
|
1045
|
+
|
1046
|
+
response = request(
|
1047
|
+
method: "POST",
|
1048
|
+
url: method_url,
|
1049
|
+
headers: headers,
|
1050
|
+
params: params,
|
1051
|
+
form: form_data,
|
1052
|
+
accept_json: true
|
1053
|
+
)
|
1054
|
+
response
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
##
|
1058
|
+
# @!method delete_stopword_list(environment_id:, collection_id:)
|
1059
|
+
# Delete a custom stopword list.
|
1060
|
+
# Delete a custom stopword list from the collection. After a custom stopword list is
|
1061
|
+
# deleted, the default list is used for the collection.
|
1062
|
+
# @param environment_id [String] The ID of the environment.
|
1063
|
+
# @param collection_id [String] The ID of the collection.
|
1064
|
+
# @return [nil]
|
1065
|
+
def delete_stopword_list(environment_id:, collection_id:)
|
1066
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
1067
|
+
|
1068
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
1069
|
+
|
1070
|
+
headers = {
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
params = {
|
1074
|
+
"version" => @version
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
method_url = "/v1/environments/%s/collections/%s/word_lists/stopwords" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(collection_id)]
|
1078
|
+
|
1079
|
+
request(
|
1080
|
+
method: "DELETE",
|
1081
|
+
url: method_url,
|
1082
|
+
headers: headers,
|
1083
|
+
params: params,
|
1084
|
+
accept_json: true
|
1085
|
+
)
|
1086
|
+
nil
|
1087
|
+
end
|
1012
1088
|
#########################
|
1013
1089
|
# Documents
|
1014
1090
|
#########################
|
@@ -2461,6 +2537,7 @@ module IBMWatson
|
|
2461
2537
|
# - `salesforce` indicates the credentials are used to connect to Salesforce.
|
2462
2538
|
# - `sharepoint` indicates the credentials are used to connect to Microsoft
|
2463
2539
|
# SharePoint Online.
|
2540
|
+
# - `web_crawl` indicates the credentials are used to perform a web crawl.
|
2464
2541
|
# @param credential_details [CredentialDetails] Object containing details of the stored credentials.
|
2465
2542
|
#
|
2466
2543
|
# Obtain credentials for your source from the administrator of the source.
|
@@ -2542,6 +2619,7 @@ module IBMWatson
|
|
2542
2619
|
# - `salesforce` indicates the credentials are used to connect to Salesforce.
|
2543
2620
|
# - `sharepoint` indicates the credentials are used to connect to Microsoft
|
2544
2621
|
# SharePoint Online.
|
2622
|
+
# - `web_crawl` indicates the credentials are used to perform a web crawl.
|
2545
2623
|
# @param credential_details [CredentialDetails] Object containing details of the stored credentials.
|
2546
2624
|
#
|
2547
2625
|
# Obtain credentials for your source from the administrator of the source.
|
@@ -2597,6 +2675,133 @@ module IBMWatson
|
|
2597
2675
|
|
2598
2676
|
method_url = "/v1/environments/%s/credentials/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(credential_id)]
|
2599
2677
|
|
2678
|
+
response = request(
|
2679
|
+
method: "DELETE",
|
2680
|
+
url: method_url,
|
2681
|
+
headers: headers,
|
2682
|
+
params: params,
|
2683
|
+
accept_json: true
|
2684
|
+
)
|
2685
|
+
response
|
2686
|
+
end
|
2687
|
+
#########################
|
2688
|
+
# gatewayConfiguration
|
2689
|
+
#########################
|
2690
|
+
|
2691
|
+
##
|
2692
|
+
# @!method list_gateways(environment_id:)
|
2693
|
+
# List Gateways.
|
2694
|
+
# List the currently configured gateways.
|
2695
|
+
# @param environment_id [String] The ID of the environment.
|
2696
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
2697
|
+
def list_gateways(environment_id:)
|
2698
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
2699
|
+
|
2700
|
+
headers = {
|
2701
|
+
}
|
2702
|
+
|
2703
|
+
params = {
|
2704
|
+
"version" => @version
|
2705
|
+
}
|
2706
|
+
|
2707
|
+
method_url = "/v1/environments/%s/gateways" % [ERB::Util.url_encode(environment_id)]
|
2708
|
+
|
2709
|
+
response = request(
|
2710
|
+
method: "GET",
|
2711
|
+
url: method_url,
|
2712
|
+
headers: headers,
|
2713
|
+
params: params,
|
2714
|
+
accept_json: true
|
2715
|
+
)
|
2716
|
+
response
|
2717
|
+
end
|
2718
|
+
|
2719
|
+
##
|
2720
|
+
# @!method create_gateway(environment_id:, name: nil)
|
2721
|
+
# Create Gateway.
|
2722
|
+
# Create a gateway configuration to use with a remotely installed gateway.
|
2723
|
+
# @param environment_id [String] The ID of the environment.
|
2724
|
+
# @param name [String] User-defined name.
|
2725
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
2726
|
+
def create_gateway(environment_id:, name: nil)
|
2727
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
2728
|
+
|
2729
|
+
headers = {
|
2730
|
+
}
|
2731
|
+
|
2732
|
+
params = {
|
2733
|
+
"version" => @version
|
2734
|
+
}
|
2735
|
+
|
2736
|
+
data = {
|
2737
|
+
"name" => name
|
2738
|
+
}
|
2739
|
+
|
2740
|
+
method_url = "/v1/environments/%s/gateways" % [ERB::Util.url_encode(environment_id)]
|
2741
|
+
|
2742
|
+
response = request(
|
2743
|
+
method: "POST",
|
2744
|
+
url: method_url,
|
2745
|
+
headers: headers,
|
2746
|
+
params: params,
|
2747
|
+
json: data,
|
2748
|
+
accept_json: true
|
2749
|
+
)
|
2750
|
+
response
|
2751
|
+
end
|
2752
|
+
|
2753
|
+
##
|
2754
|
+
# @!method get_gateway(environment_id:, gateway_id:)
|
2755
|
+
# List Gateway Details.
|
2756
|
+
# List information about the specified gateway.
|
2757
|
+
# @param environment_id [String] The ID of the environment.
|
2758
|
+
# @param gateway_id [String] The requested gateway ID.
|
2759
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
2760
|
+
def get_gateway(environment_id:, gateway_id:)
|
2761
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
2762
|
+
|
2763
|
+
raise ArgumentError.new("gateway_id must be provided") if gateway_id.nil?
|
2764
|
+
|
2765
|
+
headers = {
|
2766
|
+
}
|
2767
|
+
|
2768
|
+
params = {
|
2769
|
+
"version" => @version
|
2770
|
+
}
|
2771
|
+
|
2772
|
+
method_url = "/v1/environments/%s/gateways/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(gateway_id)]
|
2773
|
+
|
2774
|
+
response = request(
|
2775
|
+
method: "GET",
|
2776
|
+
url: method_url,
|
2777
|
+
headers: headers,
|
2778
|
+
params: params,
|
2779
|
+
accept_json: true
|
2780
|
+
)
|
2781
|
+
response
|
2782
|
+
end
|
2783
|
+
|
2784
|
+
##
|
2785
|
+
# @!method delete_gateway(environment_id:, gateway_id:)
|
2786
|
+
# Delete Gateway.
|
2787
|
+
# Delete the specified gateway configuration.
|
2788
|
+
# @param environment_id [String] The ID of the environment.
|
2789
|
+
# @param gateway_id [String] The requested gateway ID.
|
2790
|
+
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
2791
|
+
def delete_gateway(environment_id:, gateway_id:)
|
2792
|
+
raise ArgumentError.new("environment_id must be provided") if environment_id.nil?
|
2793
|
+
|
2794
|
+
raise ArgumentError.new("gateway_id must be provided") if gateway_id.nil?
|
2795
|
+
|
2796
|
+
headers = {
|
2797
|
+
}
|
2798
|
+
|
2799
|
+
params = {
|
2800
|
+
"version" => @version
|
2801
|
+
}
|
2802
|
+
|
2803
|
+
method_url = "/v1/environments/%s/gateways/%s" % [ERB::Util.url_encode(environment_id), ERB::Util.url_encode(gateway_id)]
|
2804
|
+
|
2600
2805
|
response = request(
|
2601
2806
|
method: "DELETE",
|
2602
2807
|
url: method_url,
|