@aws-amplify/predictions 5.5.6-api-v6-models.b3abc9b.0 → 6.0.1-console-preview.d745d43.0
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/README.md +3 -0
- package/lib/Predictions.d.ts +11 -45
- package/lib/Predictions.js +15 -122
- package/lib/errors/PredictionsError.d.ts +4 -0
- package/lib/errors/PredictionsError.js +19 -0
- package/lib/errors/types/validation.d.ts +14 -0
- package/lib/errors/types/validation.js +51 -0
- package/lib/errors/utils/assertValidationError.d.ts +2 -0
- package/lib/errors/utils/assertValidationError.js +14 -0
- package/lib/index.d.ts +2 -4
- package/lib/index.js +2 -9
- package/{lib-esm/Providers → lib/providers}/AmazonAIConvertPredictionsProvider.d.ts +6 -7
- package/lib/{Providers → providers}/AmazonAIConvertPredictionsProvider.js +114 -130
- package/lib/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
- package/lib/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.js +148 -191
- package/lib/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
- package/lib/providers/AmazonAIInterpretPredictionsProvider.js +280 -0
- package/lib/providers/IdentifyTextUtils.d.ts +16 -0
- package/lib/{Providers → providers}/IdentifyTextUtils.js +74 -58
- package/lib/{Providers → providers}/Utils.d.ts +2 -2
- package/lib/{Providers → providers}/Utils.js +1 -1
- package/lib/{Providers → providers}/index.d.ts +1 -2
- package/lib/providers/index.js +11 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/AWSTypes.d.ts +8 -9
- package/lib/types/AWSTypes.js +0 -1
- package/lib/types/Predictions.d.ts +63 -59
- package/lib/types/Predictions.js +28 -15
- package/lib/types/index.js +0 -1
- package/lib-esm/Predictions.d.ts +11 -45
- package/lib-esm/Predictions.js +15 -123
- package/lib-esm/errors/PredictionsError.d.ts +4 -0
- package/lib-esm/errors/PredictionsError.js +16 -0
- package/lib-esm/errors/types/validation.d.ts +14 -0
- package/lib-esm/errors/types/validation.js +48 -0
- package/lib-esm/errors/utils/assertValidationError.d.ts +2 -0
- package/lib-esm/errors/utils/assertValidationError.js +10 -0
- package/lib-esm/index.d.ts +2 -4
- package/lib-esm/index.js +1 -5
- package/{lib/Providers → lib-esm/providers}/AmazonAIConvertPredictionsProvider.d.ts +6 -7
- package/lib-esm/{Providers → providers}/AmazonAIConvertPredictionsProvider.js +106 -123
- package/lib-esm/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
- package/lib-esm/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.js +135 -179
- package/lib-esm/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
- package/lib-esm/providers/AmazonAIInterpretPredictionsProvider.js +277 -0
- package/lib-esm/providers/IdentifyTextUtils.d.ts +16 -0
- package/lib-esm/{Providers → providers}/IdentifyTextUtils.js +76 -58
- package/lib-esm/{Providers → providers}/Utils.d.ts +2 -2
- package/lib-esm/{Providers → providers}/Utils.js +0 -1
- package/lib-esm/{Providers → providers}/index.d.ts +1 -2
- package/lib-esm/{Providers → providers}/index.js +1 -3
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types/AWSTypes.d.ts +8 -9
- package/lib-esm/types/AWSTypes.js +1 -1
- package/lib-esm/types/Predictions.d.ts +63 -59
- package/lib-esm/types/Predictions.js +21 -14
- package/lib-esm/types/index.js +0 -1
- package/package.json +121 -130
- package/src/Predictions.ts +33 -220
- package/src/errors/PredictionsError.ts +16 -0
- package/src/errors/types/validation.ts +51 -0
- package/src/errors/utils/assertValidationError.ts +18 -0
- package/src/index.ts +16 -16
- package/src/{Providers → providers}/AmazonAIConvertPredictionsProvider.ts +210 -171
- package/src/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.ts +244 -246
- package/src/providers/AmazonAIInterpretPredictionsProvider.ts +293 -0
- package/src/{Providers → providers}/IdentifyTextUtils.ts +69 -52
- package/src/{Providers → providers}/Utils.ts +2 -2
- package/src/{Providers → providers}/index.ts +0 -2
- package/src/types/AWSTypes.ts +5 -6
- package/src/types/Predictions.ts +107 -62
- package/lib/.tsbuildinfo +0 -3
- package/lib/Predictions.js.map +0 -1
- package/lib/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
- package/lib/Providers/AmazonAIIdentifyPredictionsProvider.js.map +0 -1
- package/lib/Providers/AmazonAIInterpretPredictionsProvider.js +0 -321
- package/lib/Providers/AmazonAIInterpretPredictionsProvider.js.map +0 -1
- package/lib/Providers/AmazonAIPredictionsProvider.d.ts +0 -14
- package/lib/Providers/AmazonAIPredictionsProvider.js +0 -43
- package/lib/Providers/AmazonAIPredictionsProvider.js.map +0 -1
- package/lib/Providers/IdentifyTextUtils.d.ts +0 -40
- package/lib/Providers/IdentifyTextUtils.js.map +0 -1
- package/lib/Providers/Utils.js.map +0 -1
- package/lib/Providers/index.js +0 -13
- package/lib/Providers/index.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/AWSTypes.js.map +0 -1
- package/lib/types/Predictions.js.map +0 -1
- package/lib/types/Providers/AbstractConvertPredictionsProvider.d.ts +0 -9
- package/lib/types/Providers/AbstractConvertPredictionsProvider.js +0 -44
- package/lib/types/Providers/AbstractConvertPredictionsProvider.js.map +0 -1
- package/lib/types/Providers/AbstractIdentifyPredictionsProvider.d.ts +0 -9
- package/lib/types/Providers/AbstractIdentifyPredictionsProvider.js +0 -44
- package/lib/types/Providers/AbstractIdentifyPredictionsProvider.js.map +0 -1
- package/lib/types/Providers/AbstractInterpretPredictionsProvider.d.ts +0 -7
- package/lib/types/Providers/AbstractInterpretPredictionsProvider.js +0 -27
- package/lib/types/Providers/AbstractInterpretPredictionsProvider.js.map +0 -1
- package/lib/types/Providers/AbstractPredictionsProvider.d.ts +0 -7
- package/lib/types/Providers/AbstractPredictionsProvider.js +0 -16
- package/lib/types/Providers/AbstractPredictionsProvider.js.map +0 -1
- package/lib/types/Providers/index.d.ts +0 -4
- package/lib/types/Providers/index.js +0 -10
- package/lib/types/Providers/index.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/Predictions.js.map +0 -1
- package/lib-esm/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
- package/lib-esm/Providers/AmazonAIIdentifyPredictionsProvider.js.map +0 -1
- package/lib-esm/Providers/AmazonAIInterpretPredictionsProvider.js +0 -319
- package/lib-esm/Providers/AmazonAIInterpretPredictionsProvider.js.map +0 -1
- package/lib-esm/Providers/AmazonAIPredictionsProvider.d.ts +0 -14
- package/lib-esm/Providers/AmazonAIPredictionsProvider.js +0 -41
- package/lib-esm/Providers/AmazonAIPredictionsProvider.js.map +0 -1
- package/lib-esm/Providers/IdentifyTextUtils.d.ts +0 -40
- package/lib-esm/Providers/IdentifyTextUtils.js.map +0 -1
- package/lib-esm/Providers/Utils.js.map +0 -1
- package/lib-esm/Providers/index.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/types/AWSTypes.js.map +0 -1
- package/lib-esm/types/Predictions.js.map +0 -1
- package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.d.ts +0 -9
- package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js +0 -42
- package/lib-esm/types/Providers/AbstractConvertPredictionsProvider.js.map +0 -1
- package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.d.ts +0 -9
- package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.js +0 -42
- package/lib-esm/types/Providers/AbstractIdentifyPredictionsProvider.js.map +0 -1
- package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.d.ts +0 -7
- package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.js +0 -25
- package/lib-esm/types/Providers/AbstractInterpretPredictionsProvider.js.map +0 -1
- package/lib-esm/types/Providers/AbstractPredictionsProvider.d.ts +0 -7
- package/lib-esm/types/Providers/AbstractPredictionsProvider.js +0 -14
- package/lib-esm/types/Providers/AbstractPredictionsProvider.js.map +0 -1
- package/lib-esm/types/Providers/index.d.ts +0 -4
- package/lib-esm/types/Providers/index.js +0 -7
- package/lib-esm/types/Providers/index.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
- package/src/Providers/AmazonAIInterpretPredictionsProvider.ts +0 -281
- package/src/Providers/AmazonAIPredictionsProvider.ts +0 -69
- package/src/types/Providers/AbstractConvertPredictionsProvider.ts +0 -55
- package/src/types/Providers/AbstractIdentifyPredictionsProvider.ts +0 -57
- package/src/types/Providers/AbstractInterpretPredictionsProvider.ts +0 -26
- package/src/types/Providers/AbstractPredictionsProvider.ts +0 -20
- package/src/types/Providers/index.ts +0 -6
package/README.md
ADDED
package/lib/Predictions.d.ts
CHANGED
|
@@ -1,49 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbstractPredictionsProvider } from './types/Providers';
|
|
1
|
+
import { IdentifyEntitiesInput, IdentifyEntitiesOutput, IdentifyLabelsInput, IdentifyLabelsOutput, IdentifyTextInput, IdentifyTextOutput, InterpretTextInput, InterpretTextOutput, SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput } from './types';
|
|
3
2
|
export declare class PredictionsClass {
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
private _interpretPluggables;
|
|
8
|
-
/**
|
|
9
|
-
* Initialize Predictions with AWS configurations
|
|
10
|
-
* @param {PredictionsOptions} options - Configuration object for Predictions
|
|
11
|
-
*/
|
|
12
|
-
constructor(options: PredictionsOptions);
|
|
3
|
+
private convertProvider;
|
|
4
|
+
private identifyProvider;
|
|
5
|
+
private interpretProvider;
|
|
13
6
|
getModuleName(): string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @param providerName - the name of the plugin
|
|
22
|
-
*/
|
|
23
|
-
getPluggable(providerName: string): AbstractPredictionsProvider;
|
|
24
|
-
/**
|
|
25
|
-
* Remove the plugin object
|
|
26
|
-
* @param providerName - the name of the plugin
|
|
27
|
-
*/
|
|
28
|
-
removePluggable(providerName: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* To make both top level providers and category level providers work with same interface and configuration
|
|
31
|
-
* this method duplicates Predictions config into parent level config (for top level provider) and
|
|
32
|
-
* category level config (such as convert, identify etc) and pass both to each provider.
|
|
33
|
-
*/
|
|
34
|
-
configure(options: PredictionsOptions): void;
|
|
35
|
-
interpret(input: InterpretTextInput, options?: ProviderOptions): Promise<InterpretTextOutput>;
|
|
36
|
-
convert(input: TranslateTextInput, options?: ProviderOptions): Promise<TranslateTextOutput>;
|
|
37
|
-
convert(input: TextToSpeechInput, options?: ProviderOptions): Promise<TextToSpeechOutput>;
|
|
38
|
-
convert(input: SpeechToTextInput, options?: ProviderOptions): Promise<SpeechToTextOutput>;
|
|
39
|
-
identify(input: IdentifyTextInput, options?: ProviderOptions): Promise<IdentifyTextOutput>;
|
|
40
|
-
identify(input: IdentifyLabelsInput, options?: ProviderOptions): Promise<IdentifyLabelsOutput>;
|
|
41
|
-
identify(input: IdentifyEntitiesInput, options?: ProviderOptions): Promise<IdentifyEntitiesOutput>;
|
|
42
|
-
private getPluggableToExecute;
|
|
43
|
-
private getAllProviders;
|
|
44
|
-
private configurePluggable;
|
|
45
|
-
private implementsConvertPluggable;
|
|
46
|
-
private implementsIdentifyPluggable;
|
|
47
|
-
private implementsInterpretPluggable;
|
|
7
|
+
interpret(input: InterpretTextInput): Promise<InterpretTextOutput>;
|
|
8
|
+
convert(input: TranslateTextInput): Promise<TranslateTextOutput>;
|
|
9
|
+
convert(input: TextToSpeechInput): Promise<TextToSpeechOutput>;
|
|
10
|
+
convert(input: SpeechToTextInput): Promise<SpeechToTextOutput>;
|
|
11
|
+
identify(input: IdentifyTextInput): Promise<IdentifyTextOutput>;
|
|
12
|
+
identify(input: IdentifyLabelsInput): Promise<IdentifyLabelsOutput>;
|
|
13
|
+
identify(input: IdentifyEntitiesInput): Promise<IdentifyEntitiesOutput>;
|
|
48
14
|
}
|
|
49
15
|
export declare const Predictions: PredictionsClass;
|
package/lib/Predictions.js
CHANGED
|
@@ -1,137 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.Predictions = exports.PredictionsClass = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
6
|
var core_1 = require("@aws-amplify/core");
|
|
7
|
+
var providers_1 = require("./providers");
|
|
5
8
|
var logger = new core_1.ConsoleLogger('Predictions');
|
|
6
9
|
var PredictionsClass = /** @class */ (function () {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function PredictionsClass(options) {
|
|
12
|
-
this._options = options;
|
|
13
|
-
this._convertPluggables = [];
|
|
14
|
-
this._identifyPluggables = [];
|
|
15
|
-
this._interpretPluggables = [];
|
|
10
|
+
function PredictionsClass() {
|
|
11
|
+
this.convertProvider = new providers_1.AmazonAIConvertPredictionsProvider();
|
|
12
|
+
this.identifyProvider = new providers_1.AmazonAIIdentifyPredictionsProvider();
|
|
13
|
+
this.interpretProvider = new providers_1.AmazonAIInterpretPredictionsProvider();
|
|
16
14
|
}
|
|
17
15
|
PredictionsClass.prototype.getModuleName = function () {
|
|
18
16
|
return 'Predictions';
|
|
19
17
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param {Object} pluggable - an instance of the plugin/pluggable
|
|
23
|
-
**/
|
|
24
|
-
PredictionsClass.prototype.addPluggable = function (pluggable) {
|
|
25
|
-
if (this.getPluggable(pluggable.getProviderName())) {
|
|
26
|
-
throw new Error("Pluggable with name " + pluggable.getProviderName() + " has already been added.");
|
|
27
|
-
}
|
|
28
|
-
var pluggableAdded = false;
|
|
29
|
-
if (this.implementsConvertPluggable(pluggable)) {
|
|
30
|
-
this._convertPluggables.push(pluggable);
|
|
31
|
-
pluggableAdded = true;
|
|
32
|
-
}
|
|
33
|
-
if (this.implementsIdentifyPluggable(pluggable)) {
|
|
34
|
-
this._identifyPluggables.push(pluggable);
|
|
35
|
-
pluggableAdded = true;
|
|
36
|
-
}
|
|
37
|
-
if (this.implementsInterpretPluggable(pluggable)) {
|
|
38
|
-
this._interpretPluggables.push(pluggable);
|
|
39
|
-
pluggableAdded = true;
|
|
40
|
-
}
|
|
41
|
-
if (pluggableAdded) {
|
|
42
|
-
this.configurePluggable(pluggable);
|
|
43
|
-
}
|
|
18
|
+
PredictionsClass.prototype.interpret = function (input) {
|
|
19
|
+
return this.interpretProvider.interpret(input);
|
|
44
20
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* @param providerName - the name of the plugin
|
|
48
|
-
*/
|
|
49
|
-
PredictionsClass.prototype.getPluggable = function (providerName) {
|
|
50
|
-
var pluggable = this.getAllProviders().find(function (pluggable) { return pluggable.getProviderName() === providerName; });
|
|
51
|
-
if (pluggable === undefined) {
|
|
52
|
-
logger.debug('No plugin found with providerName=>', providerName);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
else
|
|
56
|
-
return pluggable;
|
|
21
|
+
PredictionsClass.prototype.convert = function (input) {
|
|
22
|
+
return this.convertProvider.convert(input);
|
|
57
23
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* @param providerName - the name of the plugin
|
|
61
|
-
*/
|
|
62
|
-
PredictionsClass.prototype.removePluggable = function (providerName) {
|
|
63
|
-
this._convertPluggables = this._convertPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
|
|
64
|
-
this._identifyPluggables = this._identifyPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
|
|
65
|
-
this._interpretPluggables = this._interpretPluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });
|
|
66
|
-
return;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* To make both top level providers and category level providers work with same interface and configuration
|
|
70
|
-
* this method duplicates Predictions config into parent level config (for top level provider) and
|
|
71
|
-
* category level config (such as convert, identify etc) and pass both to each provider.
|
|
72
|
-
*/
|
|
73
|
-
PredictionsClass.prototype.configure = function (options) {
|
|
74
|
-
var _this = this;
|
|
75
|
-
var predictionsConfig = options ? options.predictions || options : {};
|
|
76
|
-
predictionsConfig = tslib_1.__assign(tslib_1.__assign({}, predictionsConfig), options);
|
|
77
|
-
this._options = Object.assign({}, this._options, predictionsConfig);
|
|
78
|
-
logger.debug('configure Predictions', this._options);
|
|
79
|
-
this.getAllProviders().forEach(function (pluggable) {
|
|
80
|
-
return _this.configurePluggable(pluggable);
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
PredictionsClass.prototype.interpret = function (input, options) {
|
|
84
|
-
var pluggableToExecute = this.getPluggableToExecute(this._interpretPluggables, options);
|
|
85
|
-
return pluggableToExecute.interpret(input);
|
|
86
|
-
};
|
|
87
|
-
PredictionsClass.prototype.convert = function (input, options) {
|
|
88
|
-
var pluggableToExecute = this.getPluggableToExecute(this._convertPluggables, options);
|
|
89
|
-
return pluggableToExecute.convert(input);
|
|
90
|
-
};
|
|
91
|
-
PredictionsClass.prototype.identify = function (input, options) {
|
|
92
|
-
var pluggableToExecute = this.getPluggableToExecute(this._identifyPluggables, options);
|
|
93
|
-
return pluggableToExecute.identify(input);
|
|
94
|
-
};
|
|
95
|
-
// tslint:disable-next-line: max-line-length
|
|
96
|
-
PredictionsClass.prototype.getPluggableToExecute = function (pluggables, providerOptions) {
|
|
97
|
-
// Give preference to provider name first since it is more specific to this call, even if
|
|
98
|
-
// there is only one provider configured to error out if the name provided is not the one matched.
|
|
99
|
-
if (providerOptions && providerOptions.providerName) {
|
|
100
|
-
return tslib_1.__spread(pluggables).find(function (pluggable) {
|
|
101
|
-
return pluggable.getProviderName() === providerOptions.providerName;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
if (pluggables.length === 1) {
|
|
106
|
-
return pluggables[0];
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
throw new Error('More than one or no providers are configured, ' +
|
|
110
|
-
'Either specify a provider name or configure exactly one provider');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
PredictionsClass.prototype.getAllProviders = function () {
|
|
115
|
-
return tslib_1.__spread(this._convertPluggables, this._identifyPluggables, this._interpretPluggables);
|
|
116
|
-
};
|
|
117
|
-
PredictionsClass.prototype.configurePluggable = function (pluggable) {
|
|
118
|
-
var categoryConfig = Object.assign({}, this._options['predictions'], // Parent predictions config for the top level provider
|
|
119
|
-
this._options[pluggable.getCategory().toLowerCase()] // Actual category level config
|
|
120
|
-
);
|
|
121
|
-
pluggable.configure(categoryConfig);
|
|
122
|
-
};
|
|
123
|
-
PredictionsClass.prototype.implementsConvertPluggable = function (obj) {
|
|
124
|
-
return obj && typeof obj.convert === 'function';
|
|
125
|
-
};
|
|
126
|
-
PredictionsClass.prototype.implementsIdentifyPluggable = function (obj) {
|
|
127
|
-
return obj && typeof obj.identify === 'function';
|
|
128
|
-
};
|
|
129
|
-
PredictionsClass.prototype.implementsInterpretPluggable = function (obj) {
|
|
130
|
-
return obj && typeof obj.interpret === 'function';
|
|
24
|
+
PredictionsClass.prototype.identify = function (input) {
|
|
25
|
+
return this.identifyProvider.identify(input);
|
|
131
26
|
};
|
|
132
27
|
return PredictionsClass;
|
|
133
28
|
}());
|
|
134
29
|
exports.PredictionsClass = PredictionsClass;
|
|
135
|
-
exports.Predictions = new PredictionsClass(
|
|
136
|
-
core_1.Amplify.register(exports.Predictions);
|
|
137
|
-
//# sourceMappingURL=Predictions.js.map
|
|
30
|
+
exports.Predictions = new PredictionsClass();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PredictionsError = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
var PredictionsError = /** @class */ (function (_super) {
|
|
9
|
+
tslib_1.__extends(PredictionsError, _super);
|
|
10
|
+
function PredictionsError(params) {
|
|
11
|
+
var _this = _super.call(this, params) || this;
|
|
12
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
13
|
+
_this.constructor = PredictionsError;
|
|
14
|
+
Object.setPrototypeOf(_this, PredictionsError.prototype);
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
return PredictionsError;
|
|
18
|
+
}(utils_1.AmplifyError));
|
|
19
|
+
exports.PredictionsError = PredictionsError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
export declare enum PredictionsValidationErrorCode {
|
|
3
|
+
CelebrityDetectionNotEnabled = "CelebrityDetectionNotEnabled",
|
|
4
|
+
InvalidInput = "InvalidInput",
|
|
5
|
+
InvalidSource = "InvalidSource",
|
|
6
|
+
NoCredentials = "NoCredentials",
|
|
7
|
+
NoLanguage = "NoLanguage",
|
|
8
|
+
NoRegion = "NoRegion",
|
|
9
|
+
NoSource = "NoSource",
|
|
10
|
+
NoSourceLanguage = "NoSourceLanguage",
|
|
11
|
+
NoTargetLanguage = "NoTargetLanguage",
|
|
12
|
+
NoVoiceId = "NoVoiceId"
|
|
13
|
+
}
|
|
14
|
+
export declare const validationErrorMap: AmplifyErrorMap<PredictionsValidationErrorCode>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var _a;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;
|
|
7
|
+
var PredictionsValidationErrorCode;
|
|
8
|
+
(function (PredictionsValidationErrorCode) {
|
|
9
|
+
PredictionsValidationErrorCode["CelebrityDetectionNotEnabled"] = "CelebrityDetectionNotEnabled";
|
|
10
|
+
PredictionsValidationErrorCode["InvalidInput"] = "InvalidInput";
|
|
11
|
+
PredictionsValidationErrorCode["InvalidSource"] = "InvalidSource";
|
|
12
|
+
PredictionsValidationErrorCode["NoCredentials"] = "NoCredentials";
|
|
13
|
+
PredictionsValidationErrorCode["NoLanguage"] = "NoLanguage";
|
|
14
|
+
PredictionsValidationErrorCode["NoRegion"] = "NoRegion";
|
|
15
|
+
PredictionsValidationErrorCode["NoSource"] = "NoSource";
|
|
16
|
+
PredictionsValidationErrorCode["NoSourceLanguage"] = "NoSourceLanguage";
|
|
17
|
+
PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
|
|
18
|
+
PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
|
|
19
|
+
})(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));
|
|
20
|
+
exports.validationErrorMap = (_a = {},
|
|
21
|
+
_a[PredictionsValidationErrorCode.CelebrityDetectionNotEnabled] = {
|
|
22
|
+
message: 'Celebrity Detection must be enabled.',
|
|
23
|
+
},
|
|
24
|
+
_a[PredictionsValidationErrorCode.InvalidInput] = {
|
|
25
|
+
message: 'Input does not conform to expected type.',
|
|
26
|
+
},
|
|
27
|
+
_a[PredictionsValidationErrorCode.InvalidSource] = {
|
|
28
|
+
message: 'Source type not supported.',
|
|
29
|
+
},
|
|
30
|
+
_a[PredictionsValidationErrorCode.NoCredentials] = {
|
|
31
|
+
message: 'Credentials should not be empty.',
|
|
32
|
+
},
|
|
33
|
+
_a[PredictionsValidationErrorCode.NoLanguage] = {
|
|
34
|
+
message: 'Missing language.',
|
|
35
|
+
},
|
|
36
|
+
_a[PredictionsValidationErrorCode.NoRegion] = {
|
|
37
|
+
message: 'Missing region.',
|
|
38
|
+
},
|
|
39
|
+
_a[PredictionsValidationErrorCode.NoSource] = {
|
|
40
|
+
message: 'Missing source.',
|
|
41
|
+
},
|
|
42
|
+
_a[PredictionsValidationErrorCode.NoSourceLanguage] = {
|
|
43
|
+
message: 'Missing source language for translation.',
|
|
44
|
+
},
|
|
45
|
+
_a[PredictionsValidationErrorCode.NoTargetLanguage] = {
|
|
46
|
+
message: 'Missing target language for translation.',
|
|
47
|
+
},
|
|
48
|
+
_a[PredictionsValidationErrorCode.NoVoiceId] = {
|
|
49
|
+
message: 'Missing voice id.',
|
|
50
|
+
},
|
|
51
|
+
_a);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.assertValidationError = void 0;
|
|
6
|
+
var PredictionsError_1 = require("../PredictionsError");
|
|
7
|
+
var validation_1 = require("../types/validation");
|
|
8
|
+
function assertValidationError(assertion, name) {
|
|
9
|
+
if (!assertion) {
|
|
10
|
+
var _a = validation_1.validationErrorMap[name], message = _a.message, recoverySuggestion = _a.recoverySuggestion;
|
|
11
|
+
throw new PredictionsError_1.PredictionsError({ name: name, message: message, recoverySuggestion: recoverySuggestion });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.assertValidationError = assertValidationError;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from './types';
|
|
4
|
-
export { Predictions, AmazonAIIdentifyPredictionsProvider, AmazonAIConvertPredictionsProvider, AmazonAIPredictionsProvider, AmazonAIInterpretPredictionsProvider, };
|
|
1
|
+
export { Predictions } from './Predictions';
|
|
2
|
+
export { IdentifyEntitiesInput, IdentifyEntitiesOutput, IdentifyLabelsInput, IdentifyLabelsOutput, IdentifyTextInput, IdentifyTextOutput, InterpretTextInput, InterpretTextOutput, SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput, } from './types';
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.Predictions = void 0;
|
|
4
4
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
5
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
var Predictions_1 = require("./Predictions");
|
|
7
|
-
exports
|
|
8
|
-
var Providers_1 = require("./Providers");
|
|
9
|
-
exports.AmazonAIConvertPredictionsProvider = Providers_1.AmazonAIConvertPredictionsProvider;
|
|
10
|
-
exports.AmazonAIIdentifyPredictionsProvider = Providers_1.AmazonAIIdentifyPredictionsProvider;
|
|
11
|
-
exports.AmazonAIPredictionsProvider = Providers_1.AmazonAIPredictionsProvider;
|
|
12
|
-
exports.AmazonAIInterpretPredictionsProvider = Providers_1.AmazonAIInterpretPredictionsProvider;
|
|
13
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
Object.defineProperty(exports, "Predictions", { enumerable: true, get: function () { return Predictions_1.Predictions; } });
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
private
|
|
5
|
-
private pollyClient;
|
|
6
|
-
constructor();
|
|
1
|
+
import { SpeechToTextInput, SpeechToTextOutput, TextToSpeechInput, TextToSpeechOutput, TranslateTextInput, TranslateTextOutput } from '../types';
|
|
2
|
+
export declare class AmazonAIConvertPredictionsProvider {
|
|
3
|
+
private translateClient?;
|
|
4
|
+
private pollyClient?;
|
|
7
5
|
getProviderName(): string;
|
|
6
|
+
convert(input: TranslateTextInput | TextToSpeechInput | SpeechToTextInput): Promise<TextToSpeechOutput | TranslateTextOutput | SpeechToTextOutput>;
|
|
8
7
|
protected translateText(input: TranslateTextInput): Promise<TranslateTextOutput>;
|
|
9
8
|
protected convertTextToSpeech(input: TextToSpeechInput): Promise<TextToSpeechOutput>;
|
|
10
9
|
protected convertSpeechToText(input: SpeechToTextInput): Promise<SpeechToTextOutput>;
|
|
11
|
-
static serializeDataFromTranscribe(message:
|
|
10
|
+
static serializeDataFromTranscribe(message: MessageEvent): string;
|
|
12
11
|
private sendDataToTranscribe;
|
|
13
12
|
private sendEncodedDataToTranscribe;
|
|
14
13
|
private getAudioEventMessage;
|