@aws-amplify/predictions 5.5.6-api-v6-models.b3abc9b.0 → 6.0.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 +24 -132
- package/lib/errors/PredictionsError.d.ts +4 -0
- package/lib/errors/PredictionsError.js +15 -0
- package/lib/errors/types/validation.d.ts +14 -0
- package/lib/errors/types/validation.js +50 -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/AmazonAIConvertPredictionsProvider.js +307 -0
- package/lib/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
- package/lib/providers/AmazonAIIdentifyPredictionsProvider.js +334 -0
- package/lib/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
- package/lib/providers/AmazonAIInterpretPredictionsProvider.js +208 -0
- package/lib/providers/IdentifyTextUtils.d.ts +16 -0
- package/lib/{Providers → providers}/IdentifyTextUtils.js +97 -148
- package/lib/{Providers → providers}/Utils.d.ts +2 -2
- package/lib/{Providers → providers}/Utils.js +11 -12
- 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 +41 -28
- package/lib/types/index.js +1 -2
- package/lib-esm/Predictions.d.ts +11 -45
- package/lib-esm/Predictions.js +23 -133
- package/lib-esm/errors/PredictionsError.d.ts +4 -0
- package/lib-esm/errors/PredictionsError.js +11 -0
- package/lib-esm/errors/types/validation.d.ts +14 -0
- package/lib-esm/errors/types/validation.js +47 -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/AmazonAIConvertPredictionsProvider.js +303 -0
- package/lib-esm/{Providers → providers}/AmazonAIIdentifyPredictionsProvider.d.ts +5 -6
- package/lib-esm/providers/AmazonAIIdentifyPredictionsProvider.js +330 -0
- package/lib-esm/{Providers → providers}/AmazonAIInterpretPredictionsProvider.d.ts +3 -4
- package/lib-esm/providers/AmazonAIInterpretPredictionsProvider.js +204 -0
- package/lib-esm/providers/IdentifyTextUtils.d.ts +16 -0
- package/lib-esm/providers/IdentifyTextUtils.js +264 -0
- package/lib-esm/{Providers → providers}/Utils.d.ts +2 -2
- package/lib-esm/{Providers → providers}/Utils.js +10 -12
- 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 +34 -27
- package/lib-esm/types/index.js +0 -1
- package/package.json +39 -48
- 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 +0 -377
- package/lib/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
- package/lib/Providers/AmazonAIIdentifyPredictionsProvider.js +0 -441
- 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 +0 -375
- package/lib-esm/Providers/AmazonAIConvertPredictionsProvider.js.map +0 -1
- package/lib-esm/Providers/AmazonAIIdentifyPredictionsProvider.js +0 -439
- 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 +0 -313
- 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,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this._identifyPluggables = [];
|
|
15
|
-
this._interpretPluggables = [];
|
|
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
|
|
6
|
+
const core_1 = require("@aws-amplify/core");
|
|
7
|
+
const providers_1 = require("./providers");
|
|
8
|
+
const logger = new core_1.ConsoleLogger('Predictions');
|
|
9
|
+
class PredictionsClass {
|
|
10
|
+
constructor() {
|
|
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
|
+
getModuleName() {
|
|
18
16
|
return 'Predictions';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Get the plugin object
|
|
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;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Remove the plugin object
|
|
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';
|
|
131
|
-
};
|
|
132
|
-
return PredictionsClass;
|
|
133
|
-
}());
|
|
17
|
+
}
|
|
18
|
+
interpret(input) {
|
|
19
|
+
return this.interpretProvider.interpret(input);
|
|
20
|
+
}
|
|
21
|
+
convert(input) {
|
|
22
|
+
return this.convertProvider.convert(input);
|
|
23
|
+
}
|
|
24
|
+
identify(input) {
|
|
25
|
+
return this.identifyProvider.identify(input);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
134
28
|
exports.PredictionsClass = PredictionsClass;
|
|
135
|
-
exports.Predictions = new PredictionsClass(
|
|
136
|
-
core_1.Amplify.register(exports.Predictions);
|
|
137
|
-
//# sourceMappingURL=Predictions.js.map
|
|
29
|
+
exports.Predictions = new PredictionsClass();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PredictionsError = void 0;
|
|
4
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
7
|
+
class PredictionsError extends utils_1.AmplifyError {
|
|
8
|
+
constructor(params) {
|
|
9
|
+
super(params);
|
|
10
|
+
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
11
|
+
this.constructor = PredictionsError;
|
|
12
|
+
Object.setPrototypeOf(this, PredictionsError.prototype);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
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,50 @@
|
|
|
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.validationErrorMap = exports.PredictionsValidationErrorCode = void 0;
|
|
6
|
+
var PredictionsValidationErrorCode;
|
|
7
|
+
(function (PredictionsValidationErrorCode) {
|
|
8
|
+
PredictionsValidationErrorCode["CelebrityDetectionNotEnabled"] = "CelebrityDetectionNotEnabled";
|
|
9
|
+
PredictionsValidationErrorCode["InvalidInput"] = "InvalidInput";
|
|
10
|
+
PredictionsValidationErrorCode["InvalidSource"] = "InvalidSource";
|
|
11
|
+
PredictionsValidationErrorCode["NoCredentials"] = "NoCredentials";
|
|
12
|
+
PredictionsValidationErrorCode["NoLanguage"] = "NoLanguage";
|
|
13
|
+
PredictionsValidationErrorCode["NoRegion"] = "NoRegion";
|
|
14
|
+
PredictionsValidationErrorCode["NoSource"] = "NoSource";
|
|
15
|
+
PredictionsValidationErrorCode["NoSourceLanguage"] = "NoSourceLanguage";
|
|
16
|
+
PredictionsValidationErrorCode["NoTargetLanguage"] = "NoTargetLanguage";
|
|
17
|
+
PredictionsValidationErrorCode["NoVoiceId"] = "NoVoiceId";
|
|
18
|
+
})(PredictionsValidationErrorCode = exports.PredictionsValidationErrorCode || (exports.PredictionsValidationErrorCode = {}));
|
|
19
|
+
exports.validationErrorMap = {
|
|
20
|
+
[PredictionsValidationErrorCode.CelebrityDetectionNotEnabled]: {
|
|
21
|
+
message: 'Celebrity Detection must be enabled.',
|
|
22
|
+
},
|
|
23
|
+
[PredictionsValidationErrorCode.InvalidInput]: {
|
|
24
|
+
message: 'Input does not conform to expected type.',
|
|
25
|
+
},
|
|
26
|
+
[PredictionsValidationErrorCode.InvalidSource]: {
|
|
27
|
+
message: 'Source type not supported.',
|
|
28
|
+
},
|
|
29
|
+
[PredictionsValidationErrorCode.NoCredentials]: {
|
|
30
|
+
message: 'Credentials should not be empty.',
|
|
31
|
+
},
|
|
32
|
+
[PredictionsValidationErrorCode.NoLanguage]: {
|
|
33
|
+
message: 'Missing language.',
|
|
34
|
+
},
|
|
35
|
+
[PredictionsValidationErrorCode.NoRegion]: {
|
|
36
|
+
message: 'Missing region.',
|
|
37
|
+
},
|
|
38
|
+
[PredictionsValidationErrorCode.NoSource]: {
|
|
39
|
+
message: 'Missing source.',
|
|
40
|
+
},
|
|
41
|
+
[PredictionsValidationErrorCode.NoSourceLanguage]: {
|
|
42
|
+
message: 'Missing source language for translation.',
|
|
43
|
+
},
|
|
44
|
+
[PredictionsValidationErrorCode.NoTargetLanguage]: {
|
|
45
|
+
message: 'Missing target language for translation.',
|
|
46
|
+
},
|
|
47
|
+
[PredictionsValidationErrorCode.NoVoiceId]: {
|
|
48
|
+
message: 'Missing voice id.',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -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
|
+
const PredictionsError_1 = require("../PredictionsError");
|
|
7
|
+
const validation_1 = require("../types/validation");
|
|
8
|
+
function assertValidationError(assertion, name) {
|
|
9
|
+
if (!assertion) {
|
|
10
|
+
const { message, recoverySuggestion } = validation_1.validationErrorMap[name];
|
|
11
|
+
throw new PredictionsError_1.PredictionsError({ name, message, 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;
|