|
1 | 1 | /** |
2 | | -* (C) Copyright IBM Corp. 2018, 2020. |
| 2 | +* (C) Copyright IBM Corp. 2020. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -164,6 +164,73 @@ public DetailedResponse<MessageResponse> Message(string workspaceId, MessageInpu |
164 | 164 | return result; |
165 | 165 | } |
166 | 166 | /// <summary> |
| 167 | + /// Identify intents and entities in multiple user utterances. |
| 168 | + /// |
| 169 | + /// Send multiple user inputs to a workspace in a single request and receive information about the intents and |
| 170 | + /// entities recognized in each input. This method is useful for testing and comparing the performance of |
| 171 | + /// different workspaces. |
| 172 | + /// |
| 173 | + /// This method is available only with Premium plans. |
| 174 | + /// </summary> |
| 175 | + /// <param name="workspaceId">Unique identifier of the workspace.</param> |
| 176 | + /// <param name="input">An array of input utterances to classify. (optional)</param> |
| 177 | + /// <returns><see cref="BulkClassifyResponse" />BulkClassifyResponse</returns> |
| 178 | + public DetailedResponse<BulkClassifyResponse> BulkClassify(string workspaceId, List<BulkClassifyUtterance> input = null) |
| 179 | + { |
| 180 | + if (string.IsNullOrEmpty(workspaceId)) |
| 181 | + { |
| 182 | + throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`"); |
| 183 | + } |
| 184 | + else |
| 185 | + { |
| 186 | + workspaceId = Uri.EscapeDataString(workspaceId); |
| 187 | + } |
| 188 | + if (string.IsNullOrEmpty(Version)) |
| 189 | + { |
| 190 | + throw new ArgumentNullException("`Version` is required"); |
| 191 | + } |
| 192 | + DetailedResponse<BulkClassifyResponse> result = null; |
| 193 | + |
| 194 | + try |
| 195 | + { |
| 196 | + IClient client = this.Client; |
| 197 | + SetAuthentication(); |
| 198 | + |
| 199 | + var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}/bulk_classify"); |
| 200 | + |
| 201 | + restRequest.WithHeader("Accept", "application/json"); |
| 202 | + if (!string.IsNullOrEmpty(Version)) |
| 203 | + { |
| 204 | + restRequest.WithArgument("version", Version); |
| 205 | + } |
| 206 | + restRequest.WithHeader("Content-Type", "application/json"); |
| 207 | + |
| 208 | + JObject bodyObject = new JObject(); |
| 209 | + if (input != null && input.Count > 0) |
| 210 | + { |
| 211 | + bodyObject["input"] = JToken.FromObject(input); |
| 212 | + } |
| 213 | + var httpContent = new StringContent(JsonConvert.SerializeObject(bodyObject), Encoding.UTF8, HttpMediaType.APPLICATION_JSON); |
| 214 | + restRequest.WithBodyContent(httpContent); |
| 215 | + |
| 216 | + restRequest.WithHeaders(Common.GetSdkHeaders("conversation", "v1", "BulkClassify")); |
| 217 | + restRequest.WithHeaders(customRequestHeaders); |
| 218 | + ClearCustomRequestHeaders(); |
| 219 | + |
| 220 | + result = restRequest.As<BulkClassifyResponse>().Result; |
| 221 | + if (result == null) |
| 222 | + { |
| 223 | + result = new DetailedResponse<BulkClassifyResponse>(); |
| 224 | + } |
| 225 | + } |
| 226 | + catch (AggregateException ae) |
| 227 | + { |
| 228 | + throw ae.Flatten(); |
| 229 | + } |
| 230 | + |
| 231 | + return result; |
| 232 | + } |
| 233 | + /// <summary> |
167 | 234 | /// List workspaces. |
168 | 235 | /// |
169 | 236 | /// List the workspaces associated with a Watson Assistant service instance. |
@@ -4346,73 +4413,6 @@ public DetailedResponse<object> DeleteUserData(string customerId) |
4346 | 4413 | throw ae.Flatten(); |
4347 | 4414 | } |
4348 | 4415 |
|
4349 | | - return result; |
4350 | | - } |
4351 | | - /// <summary> |
4352 | | - /// Identify intents and entities in multiple user utterances. |
4353 | | - /// |
4354 | | - /// Send multiple user inputs to a workspace in a single request and receive information about the intents and |
4355 | | - /// entities recognized in each input. This method is useful for testing and comparing the performance of |
4356 | | - /// different workspaces. |
4357 | | - /// |
4358 | | - /// This method is available only with Premium plans. |
4359 | | - /// </summary> |
4360 | | - /// <param name="workspaceId">Unique identifier of the workspace.</param> |
4361 | | - /// <param name="input">An array of input utterances to classify. (optional)</param> |
4362 | | - /// <returns><see cref="BulkClassifyResponse" />BulkClassifyResponse</returns> |
4363 | | - public DetailedResponse<BulkClassifyResponse> BulkClassify(string workspaceId, List<BulkClassifyUtterance> input = null) |
4364 | | - { |
4365 | | - if (string.IsNullOrEmpty(workspaceId)) |
4366 | | - { |
4367 | | - throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`"); |
4368 | | - } |
4369 | | - else |
4370 | | - { |
4371 | | - workspaceId = Uri.EscapeDataString(workspaceId); |
4372 | | - } |
4373 | | - if (string.IsNullOrEmpty(Version)) |
4374 | | - { |
4375 | | - throw new ArgumentNullException("`Version` is required"); |
4376 | | - } |
4377 | | - DetailedResponse<BulkClassifyResponse> result = null; |
4378 | | - |
4379 | | - try |
4380 | | - { |
4381 | | - IClient client = this.Client; |
4382 | | - SetAuthentication(); |
4383 | | - |
4384 | | - var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}/bulk_classify"); |
4385 | | - |
4386 | | - restRequest.WithHeader("Accept", "application/json"); |
4387 | | - if (!string.IsNullOrEmpty(Version)) |
4388 | | - { |
4389 | | - restRequest.WithArgument("version", Version); |
4390 | | - } |
4391 | | - restRequest.WithHeader("Content-Type", "application/json"); |
4392 | | - |
4393 | | - JObject bodyObject = new JObject(); |
4394 | | - if (input != null && input.Count > 0) |
4395 | | - { |
4396 | | - bodyObject["input"] = JToken.FromObject(input); |
4397 | | - } |
4398 | | - var httpContent = new StringContent(JsonConvert.SerializeObject(bodyObject), Encoding.UTF8, HttpMediaType.APPLICATION_JSON); |
4399 | | - restRequest.WithBodyContent(httpContent); |
4400 | | - |
4401 | | - restRequest.WithHeaders(Common.GetSdkHeaders("conversation", "v1", "BulkClassify")); |
4402 | | - restRequest.WithHeaders(customRequestHeaders); |
4403 | | - ClearCustomRequestHeaders(); |
4404 | | - |
4405 | | - result = restRequest.As<BulkClassifyResponse>().Result; |
4406 | | - if (result == null) |
4407 | | - { |
4408 | | - result = new DetailedResponse<BulkClassifyResponse>(); |
4409 | | - } |
4410 | | - } |
4411 | | - catch (AggregateException ae) |
4412 | | - { |
4413 | | - throw ae.Flatten(); |
4414 | | - } |
4415 | | - |
4416 | 4416 | return result; |
4417 | 4417 | } |
4418 | 4418 | } |
|
0 commit comments