azure_cognitiveservices_luisruntime 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2.0/generated/azure_cognitiveservices_luisruntime.rb +37 -0
  4. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/luis_runtime_client.rb +131 -0
  5. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/apierror.rb +57 -0
  6. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/composite_child_model.rb +57 -0
  7. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/composite_entity_model.rb +77 -0
  8. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_model.rb +100 -0
  9. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_with_resolution.rb +94 -0
  10. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_with_score.rb +98 -0
  11. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/intent_model.rb +61 -0
  12. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/luis_result.rb +156 -0
  13. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/models/sentiment.rb +59 -0
  14. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/module_definition.rb +9 -0
  15. data/lib/2.0/generated/azure_cognitiveservices_luisruntime/prediction.rb +161 -0
  16. data/lib/azure_cognitiveservices_luisruntime.rb +6 -0
  17. data/lib/module_definition.rb +7 -0
  18. data/lib/profiles/latest/luisruntime_latest_profile_client.rb +38 -0
  19. data/lib/profiles/latest/luisruntime_module_definition.rb +8 -0
  20. data/lib/profiles/latest/modules/luisruntime_profile_module.rb +95 -0
  21. data/lib/version.rb +7 -0
  22. metadata +139 -0
@@ -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::V2_0 end
@@ -0,0 +1,161 @@
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::V2_0
7
+ #
8
+ # Prediction
9
+ #
10
+ class Prediction
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Prediction 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 predictions for a given utterance, in the form of intents and entities.
26
+ # The current maximum query size is 500 characters.
27
+ #
28
+ # @param app_id [String] The LUIS application ID (Guid).
29
+ # @param query [String] The utterance to predict.
30
+ # @param timezone_offset [Float] The timezone offset for the location of the
31
+ # request.
32
+ # @param verbose [Boolean] If true, return all intents instead of just the top
33
+ # scoring intent.
34
+ # @param staging [Boolean] Use the staging endpoint slot.
35
+ # @param spell_check [Boolean] Enable spell checking.
36
+ # @param bing_spell_check_subscription_key [String] The subscription key to use
37
+ # when enabling bing spell check
38
+ # @param log [Boolean] Log query (default is true)
39
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
40
+ # will be added to the HTTP request.
41
+ #
42
+ # @return [LuisResult] operation results.
43
+ #
44
+ def resolve(app_id, query, timezone_offset:nil, verbose:nil, staging:nil, spell_check:nil, bing_spell_check_subscription_key:nil, log:nil, custom_headers:nil)
45
+ response = resolve_async(app_id, query, timezone_offset:timezone_offset, verbose:verbose, staging:staging, spell_check:spell_check, bing_spell_check_subscription_key:bing_spell_check_subscription_key, log:log, custom_headers:custom_headers).value!
46
+ response.body unless response.nil?
47
+ end
48
+
49
+ #
50
+ # Gets predictions for a given utterance, in the form of intents and entities.
51
+ # The current maximum query size is 500 characters.
52
+ #
53
+ # @param app_id [String] The LUIS application ID (Guid).
54
+ # @param query [String] The utterance to predict.
55
+ # @param timezone_offset [Float] The timezone offset for the location of the
56
+ # request.
57
+ # @param verbose [Boolean] If true, return all intents instead of just the top
58
+ # scoring intent.
59
+ # @param staging [Boolean] Use the staging endpoint slot.
60
+ # @param spell_check [Boolean] Enable spell checking.
61
+ # @param bing_spell_check_subscription_key [String] The subscription key to use
62
+ # when enabling bing spell check
63
+ # @param log [Boolean] Log query (default is true)
64
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
65
+ # will be added to the HTTP request.
66
+ #
67
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
68
+ #
69
+ def resolve_with_http_info(app_id, query, timezone_offset:nil, verbose:nil, staging:nil, spell_check:nil, bing_spell_check_subscription_key:nil, log:nil, custom_headers:nil)
70
+ resolve_async(app_id, query, timezone_offset:timezone_offset, verbose:verbose, staging:staging, spell_check:spell_check, bing_spell_check_subscription_key:bing_spell_check_subscription_key, log:log, custom_headers:custom_headers).value!
71
+ end
72
+
73
+ #
74
+ # Gets predictions for a given utterance, in the form of intents and entities.
75
+ # The current maximum query size is 500 characters.
76
+ #
77
+ # @param app_id [String] The LUIS application ID (Guid).
78
+ # @param query [String] The utterance to predict.
79
+ # @param timezone_offset [Float] The timezone offset for the location of the
80
+ # request.
81
+ # @param verbose [Boolean] If true, return all intents instead of just the top
82
+ # scoring intent.
83
+ # @param staging [Boolean] Use the staging endpoint slot.
84
+ # @param spell_check [Boolean] Enable spell checking.
85
+ # @param bing_spell_check_subscription_key [String] The subscription key to use
86
+ # when enabling bing spell check
87
+ # @param log [Boolean] Log query (default is true)
88
+ # @param [Hash{String => String}] A hash of custom headers that will be added
89
+ # to the HTTP request.
90
+ #
91
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
92
+ #
93
+ def resolve_async(app_id, query, timezone_offset:nil, verbose:nil, staging:nil, spell_check:nil, bing_spell_check_subscription_key:nil, log:nil, custom_headers:nil)
94
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
95
+ fail ArgumentError, 'app_id is nil' if app_id.nil?
96
+ fail ArgumentError, 'query is nil' if query.nil?
97
+
98
+
99
+ request_headers = {}
100
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
101
+
102
+ # Set Headers
103
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
104
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
105
+
106
+ # Serialize Request
107
+ request_mapper = {
108
+ client_side_validation: true,
109
+ required: true,
110
+ serialized_name: 'q',
111
+ type: {
112
+ name: 'String'
113
+ }
114
+ }
115
+ request_content = @client.serialize(request_mapper, query)
116
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
117
+
118
+ path_template = 'apps/{appId}'
119
+
120
+ request_url = @base_url || @client.base_url
121
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
122
+
123
+ options = {
124
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
125
+ path_params: {'appId' => app_id},
126
+ query_params: {'timezoneOffset' => timezone_offset,'verbose' => verbose,'staging' => staging,'spellCheck' => spell_check,'bing-spell-check-subscription-key' => bing_spell_check_subscription_key,'log' => log},
127
+ body: request_content,
128
+ headers: request_headers.merge(custom_headers || {}),
129
+ base_url: request_url
130
+ }
131
+ promise = @client.make_request_async(:post, path_template, options)
132
+
133
+ promise = promise.then do |result|
134
+ http_response = result.response
135
+ status_code = http_response.status
136
+ response_content = http_response.body
137
+ unless status_code == 200
138
+ error_model = JSON.load(response_content)
139
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
140
+ end
141
+
142
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
143
+ # Deserialize Response
144
+ if status_code == 200
145
+ begin
146
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
147
+ result_mapper = Azure::CognitiveServices::LuisRuntime::V2_0::Models::LuisResult.mapper()
148
+ result.body = @client.deserialize(result_mapper, parsed_response)
149
+ rescue Exception => e
150
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
151
+ end
152
+ end
153
+
154
+ result
155
+ end
156
+
157
+ promise.execute
158
+ end
159
+
160
+ end
161
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require '2.0/generated/azure_cognitiveservices_luisruntime'
6
+ require 'profiles/latest/luisruntime_latest_profile_client'
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module Azure end
6
+ module Azure::CognitiveServices end
7
+ module Azure::CognitiveServices::LuisRuntime end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'profiles/latest/luisruntime_module_definition'
6
+ require 'profiles/latest/modules/luisruntime_profile_module'
7
+
8
+ module Azure::LuisRuntime::Profiles::Latest
9
+ #
10
+ # Client class for the Latest profile SDK.
11
+ #
12
+ class Client < LuisRuntimeDataClass
13
+ include MsRestAzure::Common::Configurable
14
+
15
+ #
16
+ # Initializes a new instance of the Client class.
17
+ # @param options [Hash] hash of client options.
18
+ # options = {
19
+ # tenant_id: 'YOUR TENANT ID',
20
+ # client_id: 'YOUR CLIENT ID',
21
+ # client_secret: 'YOUR CLIENT SECRET',
22
+ # subscription_id: 'YOUR SUBSCRIPTION ID',
23
+ # credentials: credentials,
24
+ # active_directory_settings: active_directory_settings,
25
+ # base_url: 'YOUR BASE URL',
26
+ # options: options
27
+ # }
28
+ # 'credentials' are optional and if not passed in the hash, will be obtained
29
+ # from MsRest::TokenCredentials using MsRestAzure::ApplicationTokenProvider.
30
+ #
31
+ # Also, base_url, active_directory_settings & options are optional.
32
+ #
33
+ def initialize(options = {})
34
+ super(options)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module Azure end
6
+ module Azure::LuisRuntime end
7
+ module Azure::LuisRuntime::Profiles end
8
+ module Azure::LuisRuntime::Profiles::Latest end
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'azure_cognitiveservices_luisruntime'
6
+
7
+ module Azure::LuisRuntime::Profiles::Latest
8
+ Prediction = Azure::CognitiveServices::LuisRuntime::V2_0::Prediction
9
+
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
20
+ end
21
+
22
+ #
23
+ # LuisRuntimeDataClass
24
+ #
25
+ class LuisRuntimeDataClass
26
+ attr_reader :prediction, :configurable, :base_url, :options, :model_classes
27
+
28
+ def initialize(options = {})
29
+ if options.is_a?(Hash) && options.length == 0
30
+ @options = setup_default_options
31
+ else
32
+ @options = options
33
+ end
34
+
35
+ reset!(options)
36
+
37
+ @configurable = self
38
+ @base_url = options[:base_url].nil? ? nil:options[:base_url]
39
+ @options = options[:options].nil? ? nil:options[:options]
40
+
41
+ @client_0 = Azure::CognitiveServices::LuisRuntime::V2_0::LuisRuntimeClient.new(configurable.credentials, options)
42
+ if(@client_0.respond_to?(:subscription_id))
43
+ @client_0.subscription_id = configurable.subscription_id
44
+ end
45
+ add_telemetry(@client_0)
46
+ @prediction = @client_0.prediction
47
+
48
+ @model_classes = ModelClasses.new
49
+ end
50
+
51
+ def add_telemetry(client)
52
+ profile_information = 'Profiles/Latest/LuisRuntime'
53
+ client.add_user_agent_information(profile_information)
54
+ end
55
+
56
+ def method_missing(method, *args)
57
+ if @client_0.respond_to?method
58
+ @client_0.send(method, *args)
59
+ else
60
+ super
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ class ModelClasses
67
+ def sentiment
68
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::Sentiment
69
+ end
70
+ def luis_result
71
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::LuisResult
72
+ end
73
+ def entity_model
74
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityModel
75
+ end
76
+ def composite_child_model
77
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeChildModel
78
+ end
79
+ def composite_entity_model
80
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::CompositeEntityModel
81
+ end
82
+ def intent_model
83
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::IntentModel
84
+ end
85
+ def apierror
86
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::APIError
87
+ end
88
+ def entity_with_score
89
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithScore
90
+ end
91
+ def entity_with_resolution
92
+ Azure::CognitiveServices::LuisRuntime::V2_0::Models::EntityWithResolution
93
+ end
94
+ end
95
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ module Azure::CognitiveServices::LuisRuntime
6
+ VERSION = '0.17.0'
7
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: azure_cognitiveservices_luisruntime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.17.0
5
+ platform: ruby
6
+ authors:
7
+ - Microsoft Corporation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ms_rest_azure
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.11.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.11.0
83
+ description: Microsoft Azure Cognitive Services LUIS Runtime Client Library for Ruby
84
+ email: azrubyteam@microsoft.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE.txt
90
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime.rb
91
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/luis_runtime_client.rb
92
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/apierror.rb
93
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/composite_child_model.rb
94
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/composite_entity_model.rb
95
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_model.rb
96
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_with_resolution.rb
97
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/entity_with_score.rb
98
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/intent_model.rb
99
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/luis_result.rb
100
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/models/sentiment.rb
101
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/module_definition.rb
102
+ - lib/2.0/generated/azure_cognitiveservices_luisruntime/prediction.rb
103
+ - lib/azure_cognitiveservices_luisruntime.rb
104
+ - lib/module_definition.rb
105
+ - lib/profiles/latest/luisruntime_latest_profile_client.rb
106
+ - lib/profiles/latest/luisruntime_module_definition.rb
107
+ - lib/profiles/latest/modules/luisruntime_profile_module.rb
108
+ - lib/version.rb
109
+ homepage: https://aka.ms/azure-sdk-for-ruby
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ bug_tracker_uri: https://github.com/Azure/azure-sdk-for-ruby/issues
114
+ changelog_uri: https://github.com/Azure/azure-sdk-for-ruby/blob/master/ChangeLog.md
115
+ documentation_uri: https://azure.microsoft.com/en-us/develop/ruby/
116
+ homepage_uri: https://aka.ms/azure-sdk-for-ruby
117
+ source_code_uri: https://github.com/Azure/azure-sdk-for-ruby/tree/master/data/azure_cognitiveservices_luisruntime
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 2.0.0
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.5.1
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Official Ruby client library to consume Microsoft Azure Cognitive Services
138
+ LUIS Runtime.
139
+ test_files: []