@azure/ai-text-analytics 5.2.0-alpha.20211027.1 → 5.2.0-alpha.20211130.1
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.
- package/CHANGELOG.md +20 -4
- package/dist/index.js +106 -42
- package/dist/index.js.map +1 -1
- package/dist-esm/src/analyzeActionsResult.js +13 -5
- package/dist-esm/src/analyzeActionsResult.js.map +1 -1
- package/dist-esm/src/analyzeLro.js +2 -2
- package/dist-esm/src/analyzeLro.js.map +1 -1
- package/dist-esm/src/azureKeyCredentialPolicy.js +1 -1
- package/dist-esm/src/azureKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +61 -0
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/healthLro.js +2 -2
- package/dist-esm/src/healthLro.js.map +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/textAnalyticsClient.js +2 -17
- package/dist-esm/src/textAnalyticsClient.js.map +1 -1
- package/dist-esm/src/textAnalyticsResult.js +0 -10
- package/dist-esm/src/textAnalyticsResult.js.map +1 -1
- package/dist-esm/src/util.js +27 -41
- package/dist-esm/src/util.js.map +1 -1
- package/package.json +2 -2
- package/types/ai-text-analytics.d.ts +31 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 5.2.0-beta.
|
|
3
|
+
## 5.2.0-beta.3 (Unreleased)
|
|
4
4
|
|
|
5
5
|
### Features Added
|
|
6
6
|
|
|
7
|
-
- We are now targeting the service's v3.2-preview.2 API as the default instead of v3.2-preview.1.
|
|
8
|
-
- Adding support for a three new actions in `beginAnalyzeActions`: `recognizeCustomEntities`, `singleCategoryClassify`, and `multiCategoryClassify`. The new actions allow you to use custom models to perform entity recognition and classification actions.
|
|
9
|
-
|
|
10
7
|
### Breaking Changes
|
|
11
8
|
|
|
12
9
|
### Bugs Fixed
|
|
13
10
|
|
|
14
11
|
### Other Changes
|
|
15
12
|
|
|
13
|
+
## 5.2.0-beta.2 (2021-11-02)
|
|
14
|
+
|
|
15
|
+
### Features Added
|
|
16
|
+
|
|
17
|
+
- We are now targeting the service's v3.2-preview.2 API as the default instead of v3.2-preview.1.
|
|
18
|
+
- Adding support for a three new actions in `beginAnalyzeActions`: `recognizeCustomEntities`, `singleCategoryClassify`, and `multiCategoryClassify`. The new actions allow you to use custom models to perform entity recognition and classification actions.
|
|
19
|
+
|
|
20
|
+
### Other Changes
|
|
21
|
+
|
|
22
|
+
- `beginAnalyzeActions` supports actions to be named and the name is now accessible in each action result.
|
|
23
|
+
- `beginAnalyzeActions` supports multiple actions of the same type so you can pass a list of any particular action type, e.g.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
await client.beginAnalyzeActions(docs, { recognizePiiEntitiesActions: [
|
|
27
|
+
{ modelVersion: "latest", actionName: "action1" },
|
|
28
|
+
{ modelVersion: "2021-01-15", actionName: "action2" }]
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
16
32
|
## 5.2.0-beta.1 (2021-08-09)
|
|
17
33
|
|
|
18
34
|
### Features Added
|
package/dist/index.js
CHANGED
|
@@ -239,6 +239,12 @@ const EntitiesTask = {
|
|
|
239
239
|
name: "Composite",
|
|
240
240
|
className: "EntitiesTaskParameters"
|
|
241
241
|
}
|
|
242
|
+
},
|
|
243
|
+
taskName: {
|
|
244
|
+
serializedName: "taskName",
|
|
245
|
+
type: {
|
|
246
|
+
name: "String"
|
|
247
|
+
}
|
|
242
248
|
}
|
|
243
249
|
}
|
|
244
250
|
}
|
|
@@ -282,6 +288,12 @@ const PiiTask = {
|
|
|
282
288
|
name: "Composite",
|
|
283
289
|
className: "PiiTaskParameters"
|
|
284
290
|
}
|
|
291
|
+
},
|
|
292
|
+
taskName: {
|
|
293
|
+
serializedName: "taskName",
|
|
294
|
+
type: {
|
|
295
|
+
name: "String"
|
|
296
|
+
}
|
|
285
297
|
}
|
|
286
298
|
}
|
|
287
299
|
}
|
|
@@ -346,6 +358,12 @@ const KeyPhrasesTask = {
|
|
|
346
358
|
name: "Composite",
|
|
347
359
|
className: "KeyPhrasesTaskParameters"
|
|
348
360
|
}
|
|
361
|
+
},
|
|
362
|
+
taskName: {
|
|
363
|
+
serializedName: "taskName",
|
|
364
|
+
type: {
|
|
365
|
+
name: "String"
|
|
366
|
+
}
|
|
349
367
|
}
|
|
350
368
|
}
|
|
351
369
|
}
|
|
@@ -383,6 +401,12 @@ const EntityLinkingTask = {
|
|
|
383
401
|
name: "Composite",
|
|
384
402
|
className: "EntityLinkingTaskParameters"
|
|
385
403
|
}
|
|
404
|
+
},
|
|
405
|
+
taskName: {
|
|
406
|
+
serializedName: "taskName",
|
|
407
|
+
type: {
|
|
408
|
+
name: "String"
|
|
409
|
+
}
|
|
386
410
|
}
|
|
387
411
|
}
|
|
388
412
|
}
|
|
@@ -426,6 +450,12 @@ const SentimentAnalysisTask = {
|
|
|
426
450
|
name: "Composite",
|
|
427
451
|
className: "SentimentAnalysisTaskParameters"
|
|
428
452
|
}
|
|
453
|
+
},
|
|
454
|
+
taskName: {
|
|
455
|
+
serializedName: "taskName",
|
|
456
|
+
type: {
|
|
457
|
+
name: "String"
|
|
458
|
+
}
|
|
429
459
|
}
|
|
430
460
|
}
|
|
431
461
|
}
|
|
@@ -476,6 +506,12 @@ const ExtractiveSummarizationTask = {
|
|
|
476
506
|
name: "Composite",
|
|
477
507
|
className: "ExtractiveSummarizationTaskParameters"
|
|
478
508
|
}
|
|
509
|
+
},
|
|
510
|
+
taskName: {
|
|
511
|
+
serializedName: "taskName",
|
|
512
|
+
type: {
|
|
513
|
+
name: "String"
|
|
514
|
+
}
|
|
479
515
|
}
|
|
480
516
|
}
|
|
481
517
|
}
|
|
@@ -533,6 +569,12 @@ const CustomEntitiesTask = {
|
|
|
533
569
|
name: "Composite",
|
|
534
570
|
className: "CustomEntitiesTaskParameters"
|
|
535
571
|
}
|
|
572
|
+
},
|
|
573
|
+
taskName: {
|
|
574
|
+
serializedName: "taskName",
|
|
575
|
+
type: {
|
|
576
|
+
name: "String"
|
|
577
|
+
}
|
|
536
578
|
}
|
|
537
579
|
}
|
|
538
580
|
}
|
|
@@ -583,6 +625,12 @@ const CustomSingleClassificationTask = {
|
|
|
583
625
|
name: "Composite",
|
|
584
626
|
className: "CustomSingleClassificationTaskParameters"
|
|
585
627
|
}
|
|
628
|
+
},
|
|
629
|
+
taskName: {
|
|
630
|
+
serializedName: "taskName",
|
|
631
|
+
type: {
|
|
632
|
+
name: "String"
|
|
633
|
+
}
|
|
586
634
|
}
|
|
587
635
|
}
|
|
588
636
|
}
|
|
@@ -627,6 +675,12 @@ const CustomMultiClassificationTask = {
|
|
|
627
675
|
name: "Composite",
|
|
628
676
|
className: "CustomMultiClassificationTaskParameters"
|
|
629
677
|
}
|
|
678
|
+
},
|
|
679
|
+
taskName: {
|
|
680
|
+
serializedName: "taskName",
|
|
681
|
+
type: {
|
|
682
|
+
name: "String"
|
|
683
|
+
}
|
|
630
684
|
}
|
|
631
685
|
}
|
|
632
686
|
}
|
|
@@ -1000,6 +1054,13 @@ const TaskState = {
|
|
|
1000
1054
|
name: "DateTime"
|
|
1001
1055
|
}
|
|
1002
1056
|
},
|
|
1057
|
+
taskName: {
|
|
1058
|
+
serializedName: "taskName",
|
|
1059
|
+
required: true,
|
|
1060
|
+
type: {
|
|
1061
|
+
name: "String"
|
|
1062
|
+
}
|
|
1063
|
+
},
|
|
1003
1064
|
status: {
|
|
1004
1065
|
serializedName: "status",
|
|
1005
1066
|
required: true,
|
|
@@ -3557,7 +3618,7 @@ class GeneratedClientContext extends coreClient.ServiceClient {
|
|
|
3557
3618
|
const defaults = {
|
|
3558
3619
|
requestContentType: "application/json; charset=utf-8"
|
|
3559
3620
|
};
|
|
3560
|
-
const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.
|
|
3621
|
+
const packageDetails = `azsdk-js-ai-text-analytics/5.2.0-beta.3`;
|
|
3561
3622
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
3562
3623
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
3563
3624
|
: `${packageDetails}`;
|
|
@@ -4063,32 +4124,42 @@ function addParamsToTask(action) {
|
|
|
4063
4124
|
const { actionName } = action, params = tslib.__rest(action, ["actionName"]);
|
|
4064
4125
|
return { parameters: params, taskName: actionName };
|
|
4065
4126
|
}
|
|
4127
|
+
function appendReadableErrorMessage(currentMessage, innerMessage) {
|
|
4128
|
+
let message = currentMessage;
|
|
4129
|
+
if (message.slice(-1) !== ".") {
|
|
4130
|
+
message = message + ".";
|
|
4131
|
+
}
|
|
4132
|
+
return message + " " + innerMessage;
|
|
4133
|
+
}
|
|
4066
4134
|
/**
|
|
4067
4135
|
* @internal
|
|
4068
4136
|
* parses incoming errors from the service and if the inner error code is
|
|
4069
4137
|
* InvalidDocumentBatch, it exposes that as the statusCode instead.
|
|
4070
4138
|
* @param error - the incoming error
|
|
4071
4139
|
*/
|
|
4072
|
-
function
|
|
4073
|
-
var _a
|
|
4074
|
-
const
|
|
4075
|
-
const
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
// );
|
|
4089
|
-
logger.warning(`The error coming from the service does not follow the expected structure: ${error}`);
|
|
4140
|
+
function compileError(errorResponse) {
|
|
4141
|
+
var _a;
|
|
4142
|
+
const castErrorResponse = errorResponse;
|
|
4143
|
+
const topLevelError = (_a = castErrorResponse.response.parsedBody) === null || _a === void 0 ? void 0 : _a.error;
|
|
4144
|
+
if (!topLevelError)
|
|
4145
|
+
return errorResponse;
|
|
4146
|
+
let errorMessage = topLevelError.message || "";
|
|
4147
|
+
let invalidDocumentBatchCode = false;
|
|
4148
|
+
function unwrap(error) {
|
|
4149
|
+
if ((error === null || error === void 0 ? void 0 : error.innererror) !== undefined && error.innererror.message !== undefined) {
|
|
4150
|
+
if (error.innererror.code === "InvalidDocumentBatch") {
|
|
4151
|
+
invalidDocumentBatchCode = true;
|
|
4152
|
+
}
|
|
4153
|
+
errorMessage = appendReadableErrorMessage(errorMessage, error.innererror.message);
|
|
4154
|
+
return unwrap(error.innererror);
|
|
4155
|
+
}
|
|
4090
4156
|
return error;
|
|
4091
4157
|
}
|
|
4158
|
+
unwrap(topLevelError);
|
|
4159
|
+
return new coreRestPipeline.RestError(errorMessage, {
|
|
4160
|
+
code: invalidDocumentBatchCode ? "InvalidDocumentBatch" : topLevelError.code,
|
|
4161
|
+
statusCode: castErrorResponse.statusCode
|
|
4162
|
+
});
|
|
4092
4163
|
}
|
|
4093
4164
|
/**
|
|
4094
4165
|
* @internal
|
|
@@ -4534,7 +4605,7 @@ class HealthLro {
|
|
|
4534
4605
|
};
|
|
4535
4606
|
}
|
|
4536
4607
|
catch (e) {
|
|
4537
|
-
const exception =
|
|
4608
|
+
const exception = compileError(e);
|
|
4538
4609
|
span.setStatus({
|
|
4539
4610
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
4540
4611
|
message: exception.message
|
|
@@ -4834,8 +4905,12 @@ function categorizeActionErrors(erredActions, recognizeEntitiesActionErrors, rec
|
|
|
4834
4905
|
* @param error - the error the service sent for a task
|
|
4835
4906
|
* @param lastUpdateDateTime - the time when this task failed
|
|
4836
4907
|
*/
|
|
4837
|
-
function createErredAction(error, lastUpdateDateTime) {
|
|
4838
|
-
return {
|
|
4908
|
+
function createErredAction(error, lastUpdateDateTime, taskName) {
|
|
4909
|
+
return {
|
|
4910
|
+
error: intoTextAnalyticsError(error),
|
|
4911
|
+
failedOn: lastUpdateDateTime,
|
|
4912
|
+
actionName: taskName
|
|
4913
|
+
};
|
|
4839
4914
|
}
|
|
4840
4915
|
/**
|
|
4841
4916
|
* Creates a list of results for any action.
|
|
@@ -4848,19 +4923,23 @@ function createErredAction(error, lastUpdateDateTime) {
|
|
|
4848
4923
|
function makeActionResult(documents, makeResultsArray, succeededTasks, erredActions) {
|
|
4849
4924
|
let errorIndex = 0;
|
|
4850
4925
|
function convertTasksToActions(actions, task) {
|
|
4851
|
-
const { results: actionResults, lastUpdateDateTime } = task;
|
|
4926
|
+
const { results: actionResults, lastUpdateDateTime, taskName } = task;
|
|
4852
4927
|
if (actionResults !== undefined) {
|
|
4853
4928
|
const recognizeEntitiesResults = makeResultsArray(documents, actionResults);
|
|
4854
4929
|
return [
|
|
4855
4930
|
...actions,
|
|
4856
4931
|
{
|
|
4857
4932
|
results: recognizeEntitiesResults,
|
|
4858
|
-
completedOn: lastUpdateDateTime
|
|
4933
|
+
completedOn: lastUpdateDateTime,
|
|
4934
|
+
actionName: taskName
|
|
4859
4935
|
}
|
|
4860
4936
|
];
|
|
4861
4937
|
}
|
|
4862
4938
|
else {
|
|
4863
|
-
return [
|
|
4939
|
+
return [
|
|
4940
|
+
...actions,
|
|
4941
|
+
createErredAction(erredActions[errorIndex++], lastUpdateDateTime, taskName)
|
|
4942
|
+
];
|
|
4864
4943
|
}
|
|
4865
4944
|
}
|
|
4866
4945
|
return succeededTasks.reduce(convertTasksToActions, []);
|
|
@@ -4945,7 +5024,7 @@ class AnalyzeLro {
|
|
|
4945
5024
|
};
|
|
4946
5025
|
}
|
|
4947
5026
|
catch (e) {
|
|
4948
|
-
const exception =
|
|
5027
|
+
const exception = compileError(e);
|
|
4949
5028
|
span.setStatus({
|
|
4950
5029
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
4951
5030
|
message: exception.message
|
|
@@ -5132,7 +5211,7 @@ class TextAnalyticsClient {
|
|
|
5132
5211
|
* earlier versions were throwing an exception that included the inner
|
|
5133
5212
|
* code only.
|
|
5134
5213
|
*/
|
|
5135
|
-
const backwardCompatibleException =
|
|
5214
|
+
const backwardCompatibleException = compileError(e);
|
|
5136
5215
|
span.setStatus({
|
|
5137
5216
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
5138
5217
|
message: backwardCompatibleException.message
|
|
@@ -5324,7 +5403,6 @@ class TextAnalyticsClient {
|
|
|
5324
5403
|
realInputs = documents;
|
|
5325
5404
|
realOptions = languageOrOptions || {};
|
|
5326
5405
|
}
|
|
5327
|
-
validateActions(actions);
|
|
5328
5406
|
const compiledActions = compileAnalyzeInput(actions);
|
|
5329
5407
|
const { updateIntervalInMs, resumeFrom, displayName, includeStatistics, onResponse, requestOptions, serializerOptions, abortSignal, tracingOptions } = realOptions;
|
|
5330
5408
|
const lro = new AnalyzeLro(this.client, {
|
|
@@ -5352,20 +5430,6 @@ class TextAnalyticsClient {
|
|
|
5352
5430
|
return poller;
|
|
5353
5431
|
}
|
|
5354
5432
|
}
|
|
5355
|
-
function validateActions(actions) {
|
|
5356
|
-
function validateActionType(actionList, actionType) {
|
|
5357
|
-
var _a;
|
|
5358
|
-
if (((_a = actionList === null || actionList === void 0 ? void 0 : actionList.length) !== null && _a !== void 0 ? _a : 0) > 1) {
|
|
5359
|
-
throw new Error(`beginAnalyzeActions: Currently, the service can accept up to one action only for ${actionType} actions.`);
|
|
5360
|
-
}
|
|
5361
|
-
}
|
|
5362
|
-
validateActionType(actions.analyzeSentimentActions, `analyzeSentiment`);
|
|
5363
|
-
validateActionType(actions.extractKeyPhrasesActions, `extractKeyPhrases`);
|
|
5364
|
-
validateActionType(actions.recognizeEntitiesActions, `recognizeEntities`);
|
|
5365
|
-
validateActionType(actions.recognizeLinkedEntitiesActions, `recognizeLinkedEntities`);
|
|
5366
|
-
validateActionType(actions.recognizePiiEntitiesActions, `recognizePiiEntities`);
|
|
5367
|
-
validateActionType(actions.extractSummaryActions, `extractSummary`);
|
|
5368
|
-
}
|
|
5369
5433
|
/**
|
|
5370
5434
|
* @internal
|
|
5371
5435
|
*/
|