azure_cognitiveservices_luisruntime 0.17.1 → 0.17.2

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.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/luis_runtime_client.rb +1 -1
  3. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/prediction.rb +6 -6
  4. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime.rb +39 -0
  5. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/luis_runtime_client.rb +131 -0
  6. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/dynamic_list.rb +67 -0
  7. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/error.rb +47 -0
  8. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/error_body.rb +57 -0
  9. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/external_entity.rb +80 -0
  10. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/intent.rb +58 -0
  11. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/prediction.rb +121 -0
  12. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/prediction_request.rb +101 -0
  13. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/prediction_request_options.rb +59 -0
  14. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/prediction_response.rb +58 -0
  15. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/request_list.rb +76 -0
  16. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/models/sentiment.rb +57 -0
  17. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/module_definition.rb +9 -0
  18. data/lib/3.0-preview/generated/azure_cognitiveservices_luisruntime/prediction_operations.rb +267 -0
  19. data/lib/azure_cognitiveservices_luisruntime.rb +1 -0
  20. data/lib/profiles/latest/modules/luisruntime_profile_module.rb +38 -30
  21. data/lib/version.rb +1 -1
  22. metadata +17 -2
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::CognitiveServices::LuisRuntime::V3_0_preview
7
+ module Models
8
+ #
9
+ # The result of the sentiment analysis.
10
+ #
11
+ class Sentiment
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [Float] The sentiment score of the query.
16
+ attr_accessor :score
17
+
18
+ # @return [String] The label of the sentiment analysis result.
19
+ attr_accessor :label
20
+
21
+
22
+ #
23
+ # Mapper for Sentiment class as Ruby Hash.
24
+ # This will be used for serialization/deserialization.
25
+ #
26
+ def self.mapper()
27
+ {
28
+ client_side_validation: true,
29
+ required: false,
30
+ serialized_name: 'Sentiment',
31
+ type: {
32
+ name: 'Composite',
33
+ class_name: 'Sentiment',
34
+ model_properties: {
35
+ score: {
36
+ client_side_validation: true,
37
+ required: true,
38
+ serialized_name: 'score',
39
+ type: {
40
+ name: 'Double'
41
+ }
42
+ },
43
+ label: {
44
+ client_side_validation: true,
45
+ required: false,
46
+ serialized_name: 'label',
47
+ type: {
48
+ name: 'String'
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::CognitiveServices end
8
+ module Azure::CognitiveServices::LuisRuntime end
9
+ module Azure::CognitiveServices::LuisRuntime::V3_0_preview end
@@ -0,0 +1,267 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::CognitiveServices::LuisRuntime::V3_0_preview
7
+ #
8
+ # PredictionOperations
9
+ #
10
+ class PredictionOperations
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the PredictionOperations class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [LuisRuntimeClient] reference to the LuisRuntimeClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Gets the predictions for an application version.
26
+ #
27
+ # @param app_id The application ID.
28
+ # @param version_id [String] The application version ID.
29
+ # @param prediction_request [PredictionRequest] The prediction request
30
+ # parameters.
31
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
32
+ # entities predictions or not.
33
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
34
+ # in the response or just the top intent.
35
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
36
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
37
+ # will be added to the HTTP request.
38
+ #
39
+ # @return [PredictionResponse] operation results.
40
+ #
41
+ def get_version_prediction(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
42
+ response = get_version_prediction_async(app_id, version_id, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
43
+ response.body unless response.nil?
44
+ end
45
+
46
+ #
47
+ # Gets the predictions for an application version.
48
+ #
49
+ # @param app_id The application ID.
50
+ # @param version_id [String] The application version ID.
51
+ # @param prediction_request [PredictionRequest] The prediction request
52
+ # parameters.
53
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
54
+ # entities predictions or not.
55
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
56
+ # in the response or just the top intent.
57
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
58
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
59
+ # will be added to the HTTP request.
60
+ #
61
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
62
+ #
63
+ def get_version_prediction_with_http_info(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
64
+ get_version_prediction_async(app_id, version_id, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
65
+ end
66
+
67
+ #
68
+ # Gets the predictions for an application version.
69
+ #
70
+ # @param app_id The application ID.
71
+ # @param version_id [String] The application version ID.
72
+ # @param prediction_request [PredictionRequest] The prediction request
73
+ # parameters.
74
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
75
+ # entities predictions or not.
76
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
77
+ # in the response or just the top intent.
78
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
79
+ # @param [Hash{String => String}] A hash of custom headers that will be added
80
+ # to the HTTP request.
81
+ #
82
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
83
+ #
84
+ def get_version_prediction_async(app_id, version_id, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
85
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
86
+ fail ArgumentError, 'app_id is nil' if app_id.nil?
87
+ fail ArgumentError, 'version_id is nil' if version_id.nil?
88
+ fail ArgumentError, 'prediction_request is nil' if prediction_request.nil?
89
+
90
+
91
+ request_headers = {}
92
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
93
+
94
+ # Set Headers
95
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
96
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
97
+
98
+ # Serialize Request
99
+ request_mapper = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequest.mapper()
100
+ request_content = @client.serialize(request_mapper, prediction_request)
101
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
102
+
103
+ path_template = 'apps/{appId}/versions/{versionId}/predict'
104
+
105
+ request_url = @base_url || @client.base_url
106
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
107
+
108
+ options = {
109
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
110
+ path_params: {'appId' => app_id,'versionId' => version_id},
111
+ query_params: {'verbose' => verbose,'show-all-intents' => show_all_intents,'log' => log},
112
+ body: request_content,
113
+ headers: request_headers.merge(custom_headers || {}),
114
+ base_url: request_url
115
+ }
116
+ promise = @client.make_request_async(:post, path_template, options)
117
+
118
+ promise = promise.then do |result|
119
+ http_response = result.response
120
+ status_code = http_response.status
121
+ response_content = http_response.body
122
+ unless status_code == 200
123
+ error_model = JSON.load(response_content)
124
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
125
+ end
126
+
127
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
128
+ # Deserialize Response
129
+ if status_code == 200
130
+ begin
131
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
132
+ result_mapper = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionResponse.mapper()
133
+ result.body = @client.deserialize(result_mapper, parsed_response)
134
+ rescue Exception => e
135
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
136
+ end
137
+ end
138
+
139
+ result
140
+ end
141
+
142
+ promise.execute
143
+ end
144
+
145
+ #
146
+ # Gets the predictions for an application slot.
147
+ #
148
+ # @param app_id The application ID.
149
+ # @param slot_name [String] The application slot name.
150
+ # @param prediction_request [PredictionRequest] The prediction request
151
+ # parameters.
152
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
153
+ # entities predictions or not.
154
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
155
+ # in the response or just the top intent.
156
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
157
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
158
+ # will be added to the HTTP request.
159
+ #
160
+ # @return [PredictionResponse] operation results.
161
+ #
162
+ def get_slot_prediction(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
163
+ response = get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
164
+ response.body unless response.nil?
165
+ end
166
+
167
+ #
168
+ # Gets the predictions for an application slot.
169
+ #
170
+ # @param app_id The application ID.
171
+ # @param slot_name [String] The application slot name.
172
+ # @param prediction_request [PredictionRequest] The prediction request
173
+ # parameters.
174
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
175
+ # entities predictions or not.
176
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
177
+ # in the response or just the top intent.
178
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
179
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
180
+ # will be added to the HTTP request.
181
+ #
182
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
183
+ #
184
+ def get_slot_prediction_with_http_info(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
185
+ get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:verbose, show_all_intents:show_all_intents, log:log, custom_headers:custom_headers).value!
186
+ end
187
+
188
+ #
189
+ # Gets the predictions for an application slot.
190
+ #
191
+ # @param app_id The application ID.
192
+ # @param slot_name [String] The application slot name.
193
+ # @param prediction_request [PredictionRequest] The prediction request
194
+ # parameters.
195
+ # @param verbose [Boolean] Indicates whether to get extra metadata for the
196
+ # entities predictions or not.
197
+ # @param show_all_intents [Boolean] Indicates whether to return all the intents
198
+ # in the response or just the top intent.
199
+ # @param log [Boolean] Indicates whether to log the endpoint query or not.
200
+ # @param [Hash{String => String}] A hash of custom headers that will be added
201
+ # to the HTTP request.
202
+ #
203
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
204
+ #
205
+ def get_slot_prediction_async(app_id, slot_name, prediction_request, verbose:nil, show_all_intents:nil, log:nil, custom_headers:nil)
206
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
207
+ fail ArgumentError, 'app_id is nil' if app_id.nil?
208
+ fail ArgumentError, 'slot_name is nil' if slot_name.nil?
209
+ fail ArgumentError, 'prediction_request is nil' if prediction_request.nil?
210
+
211
+
212
+ request_headers = {}
213
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
214
+
215
+ # Set Headers
216
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
217
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
218
+
219
+ # Serialize Request
220
+ request_mapper = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequest.mapper()
221
+ request_content = @client.serialize(request_mapper, prediction_request)
222
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
223
+
224
+ path_template = 'apps/{appId}/slots/{slotName}/predict'
225
+
226
+ request_url = @base_url || @client.base_url
227
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
228
+
229
+ options = {
230
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
231
+ path_params: {'appId' => app_id,'slotName' => slot_name},
232
+ query_params: {'verbose' => verbose,'show-all-intents' => show_all_intents,'log' => log},
233
+ body: request_content,
234
+ headers: request_headers.merge(custom_headers || {}),
235
+ base_url: request_url
236
+ }
237
+ promise = @client.make_request_async(:post, path_template, options)
238
+
239
+ promise = promise.then do |result|
240
+ http_response = result.response
241
+ status_code = http_response.status
242
+ response_content = http_response.body
243
+ unless status_code == 200
244
+ error_model = JSON.load(response_content)
245
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
246
+ end
247
+
248
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
249
+ # Deserialize Response
250
+ if status_code == 200
251
+ begin
252
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
253
+ result_mapper = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionResponse.mapper()
254
+ result.body = @client.deserialize(result_mapper, parsed_response)
255
+ rescue Exception => e
256
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
257
+ end
258
+ end
259
+
260
+ result
261
+ end
262
+
263
+ promise.execute
264
+ end
265
+
266
+ end
267
+ end
@@ -3,4 +3,5 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
5
  require '2.0/generated/azure_cognitiveservices_luisruntime'
6
+ require '3.0-preview/generated/azure_cognitiveservices_luisruntime'
6
7
  require 'profiles/latest/luisruntime_latest_profile_client'
@@ -5,25 +5,27 @@
5
5
  require 'azure_cognitiveservices_luisruntime'
6
6
 
7
7
  module Azure::LuisRuntime::Profiles::Latest
8
- Prediction = Azure::CognitiveServices::LuisRuntime::V2_0::Prediction
8
+ PredictionOperations = Azure::CognitiveServices::LuisRuntime::V3_0_preview::PredictionOperations
9
9
 
10
10
  module Models
11
- Sentiment = Azure::CognitiveServices::LuisRuntime::V2_0::Models::Sentiment
12
- LuisResult = Azure::CognitiveServices::LuisRuntime::V2_0::Models::LuisResult
13
- EntityModel = Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityModel
14
- CompositeChildModel = Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeChildModel
15
- CompositeEntityModel = Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeEntityModel
16
- IntentModel = Azure::CognitiveServices::LuisRuntime::V2_0::Models::IntentModel
17
- APIError = Azure::CognitiveServices::LuisRuntime::V2_0::Models::APIError
18
- EntityWithScore = Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithScore
19
- EntityWithResolution = Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithResolution
11
+ Intent = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Intent
12
+ Sentiment = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Sentiment
13
+ ExternalEntity = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::ExternalEntity
14
+ Prediction = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Prediction
15
+ DynamicList = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::DynamicList
16
+ PredictionResponse = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionResponse
17
+ PredictionRequestOptions = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequestOptions
18
+ ErrorBody = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::ErrorBody
19
+ PredictionRequest = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequest
20
+ Error = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Error
21
+ RequestList = Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::RequestList
20
22
  end
21
23
 
22
24
  #
23
25
  # LuisRuntimeDataClass
24
26
  #
25
27
  class LuisRuntimeDataClass
26
- attr_reader :prediction, :configurable, :base_url, :options, :model_classes
28
+ attr_reader :prediction_operations, :configurable, :base_url, :options, :model_classes
27
29
 
28
30
  def initialize(options = {})
29
31
  if options.is_a?(Hash) && options.length == 0
@@ -38,12 +40,12 @@ module Azure::LuisRuntime::Profiles::Latest
38
40
  @base_url = options[:base_url].nil? ? nil:options[:base_url]
39
41
  @options = options[:options].nil? ? nil:options[:options]
40
42
 
41
- @client_0 = Azure::CognitiveServices::LuisRuntime::V2_0::LuisRuntimeClient.new(configurable.credentials, options)
43
+ @client_0 = Azure::CognitiveServices::LuisRuntime::V3_0_preview::LuisRuntimeClient.new(configurable.credentials, options)
42
44
  if(@client_0.respond_to?(:subscription_id))
43
45
  @client_0.subscription_id = configurable.subscription_id
44
46
  end
45
47
  add_telemetry(@client_0)
46
- @prediction = @client_0.prediction
48
+ @prediction_operations = @client_0.prediction_operations
47
49
 
48
50
  @model_classes = ModelClasses.new
49
51
  end
@@ -64,32 +66,38 @@ module Azure::LuisRuntime::Profiles::Latest
64
66
  end
65
67
 
66
68
  class ModelClasses
69
+ def intent
70
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Intent
71
+ end
67
72
  def sentiment
68
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::Sentiment
73
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Sentiment
74
+ end
75
+ def external_entity
76
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::ExternalEntity
69
77
  end
70
- def luis_result
71
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::LuisResult
78
+ def prediction
79
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Prediction
72
80
  end
73
- def entity_model
74
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityModel
81
+ def dynamic_list
82
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::DynamicList
75
83
  end
76
- def composite_child_model
77
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeChildModel
84
+ def prediction_response
85
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionResponse
78
86
  end
79
- def composite_entity_model
80
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeEntityModel
87
+ def prediction_request_options
88
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequestOptions
81
89
  end
82
- def intent_model
83
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::IntentModel
90
+ def error_body
91
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::ErrorBody
84
92
  end
85
- def apierror
86
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::APIError
93
+ def prediction_request
94
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::PredictionRequest
87
95
  end
88
- def entity_with_score
89
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithScore
96
+ def error
97
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::Error
90
98
  end
91
- def entity_with_resolution
92
- Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithResolution
99
+ def request_list
100
+ Azure::CognitiveServices::LuisRuntime::V3_0_preview::Models::RequestList
93
101
  end
94
102
  end
95
103
  end