@aws-sdk/client-bedrock-runtime 3.613.0 → 3.616.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 +8 -0
- package/dist-cjs/index.js +363 -185
- package/dist-es/BedrockRuntime.js +2 -0
- package/dist-es/BedrockRuntimeClient.js +5 -5
- package/dist-es/commands/ApplyGuardrailCommand.js +24 -0
- package/dist-es/commands/index.js +1 -0
- package/dist-es/models/models_0.js +160 -126
- package/dist-es/protocols/Aws_restJson1.js +128 -15
- package/dist-types/BedrockRuntime.d.ts +7 -0
- package/dist-types/BedrockRuntimeClient.d.ts +5 -4
- package/dist-types/commands/ApplyGuardrailCommand.d.ts +167 -0
- package/dist-types/commands/ConverseCommand.d.ts +29 -0
- package/dist-types/commands/ConverseStreamCommand.d.ts +26 -0
- package/dist-types/commands/index.d.ts +1 -0
- package/dist-types/models/models_0.d.ts +1138 -840
- package/dist-types/protocols/Aws_restJson1.d.ts +9 -0
- package/dist-types/runtimeConfig.browser.d.ts +1 -1
- package/dist-types/runtimeConfig.d.ts +1 -1
- package/dist-types/runtimeConfig.native.d.ts +1 -1
- package/dist-types/ts3.4/BedrockRuntime.d.ts +17 -0
- package/dist-types/ts3.4/BedrockRuntimeClient.d.ts +8 -2
- package/dist-types/ts3.4/commands/ApplyGuardrailCommand.d.ts +39 -0
- package/dist-types/ts3.4/commands/index.d.ts +1 -0
- package/dist-types/ts3.4/models/models_0.d.ts +263 -169
- package/dist-types/ts3.4/protocols/Aws_restJson1.d.ts +12 -0
- package/dist-types/ts3.4/runtimeConfig.browser.d.ts +1 -1
- package/dist-types/ts3.4/runtimeConfig.d.ts +1 -1
- package/dist-types/ts3.4/runtimeConfig.native.d.ts +1 -1
- package/package.json +25 -25
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { createAggregatedClient } from "@smithy/smithy-client";
|
|
2
2
|
import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
|
|
3
|
+
import { ApplyGuardrailCommand, } from "./commands/ApplyGuardrailCommand";
|
|
3
4
|
import { ConverseCommand } from "./commands/ConverseCommand";
|
|
4
5
|
import { ConverseStreamCommand, } from "./commands/ConverseStreamCommand";
|
|
5
6
|
import { InvokeModelCommand } from "./commands/InvokeModelCommand";
|
|
6
7
|
import { InvokeModelWithResponseStreamCommand, } from "./commands/InvokeModelWithResponseStreamCommand";
|
|
7
8
|
const commands = {
|
|
9
|
+
ApplyGuardrailCommand,
|
|
8
10
|
ConverseCommand,
|
|
9
11
|
ConverseStreamCommand,
|
|
10
12
|
InvokeModelCommand,
|
|
@@ -20,20 +20,20 @@ export class BedrockRuntimeClient extends __Client {
|
|
|
20
20
|
const _config_1 = resolveClientEndpointParameters(_config_0);
|
|
21
21
|
const _config_2 = resolveRegionConfig(_config_1);
|
|
22
22
|
const _config_3 = resolveEndpointConfig(_config_2);
|
|
23
|
-
const _config_4 =
|
|
24
|
-
const _config_5 =
|
|
25
|
-
const _config_6 =
|
|
23
|
+
const _config_4 = resolveHostHeaderConfig(_config_3);
|
|
24
|
+
const _config_5 = resolveUserAgentConfig(_config_4);
|
|
25
|
+
const _config_6 = resolveRetryConfig(_config_5);
|
|
26
26
|
const _config_7 = resolveEventStreamSerdeConfig(_config_6);
|
|
27
27
|
const _config_8 = resolveHttpAuthSchemeConfig(_config_7);
|
|
28
28
|
const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []);
|
|
29
29
|
super(_config_9);
|
|
30
30
|
this.config = _config_9;
|
|
31
|
-
this.middlewareStack.use(getRetryPlugin(this.config));
|
|
32
|
-
this.middlewareStack.use(getContentLengthPlugin(this.config));
|
|
33
31
|
this.middlewareStack.use(getHostHeaderPlugin(this.config));
|
|
34
32
|
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
35
33
|
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
36
34
|
this.middlewareStack.use(getUserAgentPlugin(this.config));
|
|
35
|
+
this.middlewareStack.use(getRetryPlugin(this.config));
|
|
36
|
+
this.middlewareStack.use(getContentLengthPlugin(this.config));
|
|
37
37
|
this.middlewareStack.use(getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
38
38
|
httpAuthSchemeParametersProvider: this.getDefaultHttpAuthSchemeParametersProvider(),
|
|
39
39
|
identityProviderConfigProvider: this.getIdentityProviderConfigProvider(),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
|
|
2
|
+
import { getSerdePlugin } from "@smithy/middleware-serde";
|
|
3
|
+
import { Command as $Command } from "@smithy/smithy-client";
|
|
4
|
+
import { commonParams } from "../endpoint/EndpointParameters";
|
|
5
|
+
import { de_ApplyGuardrailCommand, se_ApplyGuardrailCommand } from "../protocols/Aws_restJson1";
|
|
6
|
+
export { $Command };
|
|
7
|
+
export class ApplyGuardrailCommand extends $Command
|
|
8
|
+
.classBuilder()
|
|
9
|
+
.ep({
|
|
10
|
+
...commonParams,
|
|
11
|
+
})
|
|
12
|
+
.m(function (Command, cs, config, o) {
|
|
13
|
+
return [
|
|
14
|
+
getSerdePlugin(config, this.serialize, this.deserialize),
|
|
15
|
+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
|
|
16
|
+
];
|
|
17
|
+
})
|
|
18
|
+
.s("AmazonBedrockFrontendService", "ApplyGuardrail", {})
|
|
19
|
+
.n("BedrockRuntimeClient", "ApplyGuardrailCommand")
|
|
20
|
+
.f(void 0, void 0)
|
|
21
|
+
.ser(se_ApplyGuardrailCommand)
|
|
22
|
+
.de(de_ApplyGuardrailCommand)
|
|
23
|
+
.build() {
|
|
24
|
+
}
|
|
@@ -12,6 +12,161 @@ export class AccessDeniedException extends __BaseException {
|
|
|
12
12
|
Object.setPrototypeOf(this, AccessDeniedException.prototype);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
export const GuardrailContentQualifier = {
|
|
16
|
+
GROUNDING_SOURCE: "grounding_source",
|
|
17
|
+
GUARD_CONTENT: "guard_content",
|
|
18
|
+
QUERY: "query",
|
|
19
|
+
};
|
|
20
|
+
export var GuardrailContentBlock;
|
|
21
|
+
(function (GuardrailContentBlock) {
|
|
22
|
+
GuardrailContentBlock.visit = (value, visitor) => {
|
|
23
|
+
if (value.text !== undefined)
|
|
24
|
+
return visitor.text(value.text);
|
|
25
|
+
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
26
|
+
};
|
|
27
|
+
})(GuardrailContentBlock || (GuardrailContentBlock = {}));
|
|
28
|
+
export const GuardrailContentSource = {
|
|
29
|
+
INPUT: "INPUT",
|
|
30
|
+
OUTPUT: "OUTPUT",
|
|
31
|
+
};
|
|
32
|
+
export const GuardrailAction = {
|
|
33
|
+
GUARDRAIL_INTERVENED: "GUARDRAIL_INTERVENED",
|
|
34
|
+
NONE: "NONE",
|
|
35
|
+
};
|
|
36
|
+
export const GuardrailContentPolicyAction = {
|
|
37
|
+
BLOCKED: "BLOCKED",
|
|
38
|
+
};
|
|
39
|
+
export const GuardrailContentFilterConfidence = {
|
|
40
|
+
HIGH: "HIGH",
|
|
41
|
+
LOW: "LOW",
|
|
42
|
+
MEDIUM: "MEDIUM",
|
|
43
|
+
NONE: "NONE",
|
|
44
|
+
};
|
|
45
|
+
export const GuardrailContentFilterType = {
|
|
46
|
+
HATE: "HATE",
|
|
47
|
+
INSULTS: "INSULTS",
|
|
48
|
+
MISCONDUCT: "MISCONDUCT",
|
|
49
|
+
PROMPT_ATTACK: "PROMPT_ATTACK",
|
|
50
|
+
SEXUAL: "SEXUAL",
|
|
51
|
+
VIOLENCE: "VIOLENCE",
|
|
52
|
+
};
|
|
53
|
+
export const GuardrailContextualGroundingPolicyAction = {
|
|
54
|
+
BLOCKED: "BLOCKED",
|
|
55
|
+
NONE: "NONE",
|
|
56
|
+
};
|
|
57
|
+
export const GuardrailContextualGroundingFilterType = {
|
|
58
|
+
GROUNDING: "GROUNDING",
|
|
59
|
+
RELEVANCE: "RELEVANCE",
|
|
60
|
+
};
|
|
61
|
+
export const GuardrailSensitiveInformationPolicyAction = {
|
|
62
|
+
ANONYMIZED: "ANONYMIZED",
|
|
63
|
+
BLOCKED: "BLOCKED",
|
|
64
|
+
};
|
|
65
|
+
export const GuardrailPiiEntityType = {
|
|
66
|
+
ADDRESS: "ADDRESS",
|
|
67
|
+
AGE: "AGE",
|
|
68
|
+
AWS_ACCESS_KEY: "AWS_ACCESS_KEY",
|
|
69
|
+
AWS_SECRET_KEY: "AWS_SECRET_KEY",
|
|
70
|
+
CA_HEALTH_NUMBER: "CA_HEALTH_NUMBER",
|
|
71
|
+
CA_SOCIAL_INSURANCE_NUMBER: "CA_SOCIAL_INSURANCE_NUMBER",
|
|
72
|
+
CREDIT_DEBIT_CARD_CVV: "CREDIT_DEBIT_CARD_CVV",
|
|
73
|
+
CREDIT_DEBIT_CARD_EXPIRY: "CREDIT_DEBIT_CARD_EXPIRY",
|
|
74
|
+
CREDIT_DEBIT_CARD_NUMBER: "CREDIT_DEBIT_CARD_NUMBER",
|
|
75
|
+
DRIVER_ID: "DRIVER_ID",
|
|
76
|
+
EMAIL: "EMAIL",
|
|
77
|
+
INTERNATIONAL_BANK_ACCOUNT_NUMBER: "INTERNATIONAL_BANK_ACCOUNT_NUMBER",
|
|
78
|
+
IP_ADDRESS: "IP_ADDRESS",
|
|
79
|
+
LICENSE_PLATE: "LICENSE_PLATE",
|
|
80
|
+
MAC_ADDRESS: "MAC_ADDRESS",
|
|
81
|
+
NAME: "NAME",
|
|
82
|
+
PASSWORD: "PASSWORD",
|
|
83
|
+
PHONE: "PHONE",
|
|
84
|
+
PIN: "PIN",
|
|
85
|
+
SWIFT_CODE: "SWIFT_CODE",
|
|
86
|
+
UK_NATIONAL_HEALTH_SERVICE_NUMBER: "UK_NATIONAL_HEALTH_SERVICE_NUMBER",
|
|
87
|
+
UK_NATIONAL_INSURANCE_NUMBER: "UK_NATIONAL_INSURANCE_NUMBER",
|
|
88
|
+
UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER: "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER",
|
|
89
|
+
URL: "URL",
|
|
90
|
+
USERNAME: "USERNAME",
|
|
91
|
+
US_BANK_ACCOUNT_NUMBER: "US_BANK_ACCOUNT_NUMBER",
|
|
92
|
+
US_BANK_ROUTING_NUMBER: "US_BANK_ROUTING_NUMBER",
|
|
93
|
+
US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER: "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
|
|
94
|
+
US_PASSPORT_NUMBER: "US_PASSPORT_NUMBER",
|
|
95
|
+
US_SOCIAL_SECURITY_NUMBER: "US_SOCIAL_SECURITY_NUMBER",
|
|
96
|
+
VEHICLE_IDENTIFICATION_NUMBER: "VEHICLE_IDENTIFICATION_NUMBER",
|
|
97
|
+
};
|
|
98
|
+
export const GuardrailTopicPolicyAction = {
|
|
99
|
+
BLOCKED: "BLOCKED",
|
|
100
|
+
};
|
|
101
|
+
export const GuardrailTopicType = {
|
|
102
|
+
DENY: "DENY",
|
|
103
|
+
};
|
|
104
|
+
export const GuardrailWordPolicyAction = {
|
|
105
|
+
BLOCKED: "BLOCKED",
|
|
106
|
+
};
|
|
107
|
+
export const GuardrailManagedWordType = {
|
|
108
|
+
PROFANITY: "PROFANITY",
|
|
109
|
+
};
|
|
110
|
+
export class InternalServerException extends __BaseException {
|
|
111
|
+
constructor(opts) {
|
|
112
|
+
super({
|
|
113
|
+
name: "InternalServerException",
|
|
114
|
+
$fault: "server",
|
|
115
|
+
...opts,
|
|
116
|
+
});
|
|
117
|
+
this.name = "InternalServerException";
|
|
118
|
+
this.$fault = "server";
|
|
119
|
+
Object.setPrototypeOf(this, InternalServerException.prototype);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export class ResourceNotFoundException extends __BaseException {
|
|
123
|
+
constructor(opts) {
|
|
124
|
+
super({
|
|
125
|
+
name: "ResourceNotFoundException",
|
|
126
|
+
$fault: "client",
|
|
127
|
+
...opts,
|
|
128
|
+
});
|
|
129
|
+
this.name = "ResourceNotFoundException";
|
|
130
|
+
this.$fault = "client";
|
|
131
|
+
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export class ServiceQuotaExceededException extends __BaseException {
|
|
135
|
+
constructor(opts) {
|
|
136
|
+
super({
|
|
137
|
+
name: "ServiceQuotaExceededException",
|
|
138
|
+
$fault: "client",
|
|
139
|
+
...opts,
|
|
140
|
+
});
|
|
141
|
+
this.name = "ServiceQuotaExceededException";
|
|
142
|
+
this.$fault = "client";
|
|
143
|
+
Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export class ThrottlingException extends __BaseException {
|
|
147
|
+
constructor(opts) {
|
|
148
|
+
super({
|
|
149
|
+
name: "ThrottlingException",
|
|
150
|
+
$fault: "client",
|
|
151
|
+
...opts,
|
|
152
|
+
});
|
|
153
|
+
this.name = "ThrottlingException";
|
|
154
|
+
this.$fault = "client";
|
|
155
|
+
Object.setPrototypeOf(this, ThrottlingException.prototype);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export class ValidationException extends __BaseException {
|
|
159
|
+
constructor(opts) {
|
|
160
|
+
super({
|
|
161
|
+
name: "ValidationException",
|
|
162
|
+
$fault: "client",
|
|
163
|
+
...opts,
|
|
164
|
+
});
|
|
165
|
+
this.name = "ValidationException";
|
|
166
|
+
this.$fault = "client";
|
|
167
|
+
Object.setPrototypeOf(this, ValidationException.prototype);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
15
170
|
export const GuardrailTrace = {
|
|
16
171
|
DISABLED: "disabled",
|
|
17
172
|
ENABLED: "enabled",
|
|
@@ -35,6 +190,11 @@ export var DocumentSource;
|
|
|
35
190
|
return visitor._(value.$unknown[0], value.$unknown[1]);
|
|
36
191
|
};
|
|
37
192
|
})(DocumentSource || (DocumentSource = {}));
|
|
193
|
+
export const GuardrailConverseContentQualifier = {
|
|
194
|
+
GROUNDING_SOURCE: "grounding_source",
|
|
195
|
+
GUARD_CONTENT: "guard_content",
|
|
196
|
+
QUERY: "query",
|
|
197
|
+
};
|
|
38
198
|
export var GuardrailConverseContentBlock;
|
|
39
199
|
(function (GuardrailConverseContentBlock) {
|
|
40
200
|
GuardrailConverseContentBlock.visit = (value, visitor) => {
|
|
@@ -151,84 +311,6 @@ export const StopReason = {
|
|
|
151
311
|
STOP_SEQUENCE: "stop_sequence",
|
|
152
312
|
TOOL_USE: "tool_use",
|
|
153
313
|
};
|
|
154
|
-
export const GuardrailContentPolicyAction = {
|
|
155
|
-
BLOCKED: "BLOCKED",
|
|
156
|
-
};
|
|
157
|
-
export const GuardrailContentFilterConfidence = {
|
|
158
|
-
HIGH: "HIGH",
|
|
159
|
-
LOW: "LOW",
|
|
160
|
-
MEDIUM: "MEDIUM",
|
|
161
|
-
NONE: "NONE",
|
|
162
|
-
};
|
|
163
|
-
export const GuardrailContentFilterType = {
|
|
164
|
-
HATE: "HATE",
|
|
165
|
-
INSULTS: "INSULTS",
|
|
166
|
-
MISCONDUCT: "MISCONDUCT",
|
|
167
|
-
PROMPT_ATTACK: "PROMPT_ATTACK",
|
|
168
|
-
SEXUAL: "SEXUAL",
|
|
169
|
-
VIOLENCE: "VIOLENCE",
|
|
170
|
-
};
|
|
171
|
-
export const GuardrailSensitiveInformationPolicyAction = {
|
|
172
|
-
ANONYMIZED: "ANONYMIZED",
|
|
173
|
-
BLOCKED: "BLOCKED",
|
|
174
|
-
};
|
|
175
|
-
export const GuardrailPiiEntityType = {
|
|
176
|
-
ADDRESS: "ADDRESS",
|
|
177
|
-
AGE: "AGE",
|
|
178
|
-
AWS_ACCESS_KEY: "AWS_ACCESS_KEY",
|
|
179
|
-
AWS_SECRET_KEY: "AWS_SECRET_KEY",
|
|
180
|
-
CA_HEALTH_NUMBER: "CA_HEALTH_NUMBER",
|
|
181
|
-
CA_SOCIAL_INSURANCE_NUMBER: "CA_SOCIAL_INSURANCE_NUMBER",
|
|
182
|
-
CREDIT_DEBIT_CARD_CVV: "CREDIT_DEBIT_CARD_CVV",
|
|
183
|
-
CREDIT_DEBIT_CARD_EXPIRY: "CREDIT_DEBIT_CARD_EXPIRY",
|
|
184
|
-
CREDIT_DEBIT_CARD_NUMBER: "CREDIT_DEBIT_CARD_NUMBER",
|
|
185
|
-
DRIVER_ID: "DRIVER_ID",
|
|
186
|
-
EMAIL: "EMAIL",
|
|
187
|
-
INTERNATIONAL_BANK_ACCOUNT_NUMBER: "INTERNATIONAL_BANK_ACCOUNT_NUMBER",
|
|
188
|
-
IP_ADDRESS: "IP_ADDRESS",
|
|
189
|
-
LICENSE_PLATE: "LICENSE_PLATE",
|
|
190
|
-
MAC_ADDRESS: "MAC_ADDRESS",
|
|
191
|
-
NAME: "NAME",
|
|
192
|
-
PASSWORD: "PASSWORD",
|
|
193
|
-
PHONE: "PHONE",
|
|
194
|
-
PIN: "PIN",
|
|
195
|
-
SWIFT_CODE: "SWIFT_CODE",
|
|
196
|
-
UK_NATIONAL_HEALTH_SERVICE_NUMBER: "UK_NATIONAL_HEALTH_SERVICE_NUMBER",
|
|
197
|
-
UK_NATIONAL_INSURANCE_NUMBER: "UK_NATIONAL_INSURANCE_NUMBER",
|
|
198
|
-
UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER: "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER",
|
|
199
|
-
URL: "URL",
|
|
200
|
-
USERNAME: "USERNAME",
|
|
201
|
-
US_BANK_ACCOUNT_NUMBER: "US_BANK_ACCOUNT_NUMBER",
|
|
202
|
-
US_BANK_ROUTING_NUMBER: "US_BANK_ROUTING_NUMBER",
|
|
203
|
-
US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER: "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER",
|
|
204
|
-
US_PASSPORT_NUMBER: "US_PASSPORT_NUMBER",
|
|
205
|
-
US_SOCIAL_SECURITY_NUMBER: "US_SOCIAL_SECURITY_NUMBER",
|
|
206
|
-
VEHICLE_IDENTIFICATION_NUMBER: "VEHICLE_IDENTIFICATION_NUMBER",
|
|
207
|
-
};
|
|
208
|
-
export const GuardrailTopicPolicyAction = {
|
|
209
|
-
BLOCKED: "BLOCKED",
|
|
210
|
-
};
|
|
211
|
-
export const GuardrailTopicType = {
|
|
212
|
-
DENY: "DENY",
|
|
213
|
-
};
|
|
214
|
-
export const GuardrailWordPolicyAction = {
|
|
215
|
-
BLOCKED: "BLOCKED",
|
|
216
|
-
};
|
|
217
|
-
export const GuardrailManagedWordType = {
|
|
218
|
-
PROFANITY: "PROFANITY",
|
|
219
|
-
};
|
|
220
|
-
export class InternalServerException extends __BaseException {
|
|
221
|
-
constructor(opts) {
|
|
222
|
-
super({
|
|
223
|
-
name: "InternalServerException",
|
|
224
|
-
$fault: "server",
|
|
225
|
-
...opts,
|
|
226
|
-
});
|
|
227
|
-
this.name = "InternalServerException";
|
|
228
|
-
this.$fault = "server";
|
|
229
|
-
Object.setPrototypeOf(this, InternalServerException.prototype);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
314
|
export class ModelErrorException extends __BaseException {
|
|
233
315
|
constructor(opts) {
|
|
234
316
|
super({
|
|
@@ -267,42 +349,6 @@ export class ModelTimeoutException extends __BaseException {
|
|
|
267
349
|
Object.setPrototypeOf(this, ModelTimeoutException.prototype);
|
|
268
350
|
}
|
|
269
351
|
}
|
|
270
|
-
export class ResourceNotFoundException extends __BaseException {
|
|
271
|
-
constructor(opts) {
|
|
272
|
-
super({
|
|
273
|
-
name: "ResourceNotFoundException",
|
|
274
|
-
$fault: "client",
|
|
275
|
-
...opts,
|
|
276
|
-
});
|
|
277
|
-
this.name = "ResourceNotFoundException";
|
|
278
|
-
this.$fault = "client";
|
|
279
|
-
Object.setPrototypeOf(this, ResourceNotFoundException.prototype);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
export class ThrottlingException extends __BaseException {
|
|
283
|
-
constructor(opts) {
|
|
284
|
-
super({
|
|
285
|
-
name: "ThrottlingException",
|
|
286
|
-
$fault: "client",
|
|
287
|
-
...opts,
|
|
288
|
-
});
|
|
289
|
-
this.name = "ThrottlingException";
|
|
290
|
-
this.$fault = "client";
|
|
291
|
-
Object.setPrototypeOf(this, ThrottlingException.prototype);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
export class ValidationException extends __BaseException {
|
|
295
|
-
constructor(opts) {
|
|
296
|
-
super({
|
|
297
|
-
name: "ValidationException",
|
|
298
|
-
$fault: "client",
|
|
299
|
-
...opts,
|
|
300
|
-
});
|
|
301
|
-
this.name = "ValidationException";
|
|
302
|
-
this.$fault = "client";
|
|
303
|
-
Object.setPrototypeOf(this, ValidationException.prototype);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
352
|
export const GuardrailStreamProcessingMode = {
|
|
307
353
|
ASYNC: "async",
|
|
308
354
|
SYNC: "sync",
|
|
@@ -369,18 +415,6 @@ export const Trace = {
|
|
|
369
415
|
DISABLED: "DISABLED",
|
|
370
416
|
ENABLED: "ENABLED",
|
|
371
417
|
};
|
|
372
|
-
export class ServiceQuotaExceededException extends __BaseException {
|
|
373
|
-
constructor(opts) {
|
|
374
|
-
super({
|
|
375
|
-
name: "ServiceQuotaExceededException",
|
|
376
|
-
$fault: "client",
|
|
377
|
-
...opts,
|
|
378
|
-
});
|
|
379
|
-
this.name = "ServiceQuotaExceededException";
|
|
380
|
-
this.$fault = "client";
|
|
381
|
-
Object.setPrototypeOf(this, ServiceQuotaExceededException.prototype);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
418
|
export var ResponseStream;
|
|
385
419
|
(function (ResponseStream) {
|
|
386
420
|
ResponseStream.visit = (value, visitor) => {
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { awsExpectUnion as __expectUnion, loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody, } from "@aws-sdk/core";
|
|
2
2
|
import { requestBuilder as rb } from "@smithy/core";
|
|
3
|
-
import { _json, collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, map, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
|
|
3
|
+
import { _json, collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, limitedParseDouble as __limitedParseDouble, map, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
|
|
4
4
|
import { BedrockRuntimeServiceException as __BaseException } from "../models/BedrockRuntimeServiceException";
|
|
5
5
|
import { AccessDeniedException, ContentBlock, DocumentSource, ImageSource, InternalServerException, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, Tool, ToolInputSchema, ToolResultContentBlock, ValidationException, } from "../models/models_0";
|
|
6
|
+
export const se_ApplyGuardrailCommand = async (input, context) => {
|
|
7
|
+
const b = rb(input, context);
|
|
8
|
+
const headers = {
|
|
9
|
+
"content-type": "application/json",
|
|
10
|
+
};
|
|
11
|
+
b.bp("/guardrail/{guardrailIdentifier}/version/{guardrailVersion}/apply");
|
|
12
|
+
b.p("guardrailIdentifier", () => input.guardrailIdentifier, "{guardrailIdentifier}", false);
|
|
13
|
+
b.p("guardrailVersion", () => input.guardrailVersion, "{guardrailVersion}", false);
|
|
14
|
+
let body;
|
|
15
|
+
body = JSON.stringify(take(input, {
|
|
16
|
+
content: (_) => _json(_),
|
|
17
|
+
source: [],
|
|
18
|
+
}));
|
|
19
|
+
b.m("POST").h(headers).b(body);
|
|
20
|
+
return b.build();
|
|
21
|
+
};
|
|
6
22
|
export const se_ConverseCommand = async (input, context) => {
|
|
7
23
|
const b = rb(input, context);
|
|
8
24
|
const headers = {
|
|
@@ -79,6 +95,23 @@ export const se_InvokeModelWithResponseStreamCommand = async (input, context) =>
|
|
|
79
95
|
b.m("POST").h(headers).b(body);
|
|
80
96
|
return b.build();
|
|
81
97
|
};
|
|
98
|
+
export const de_ApplyGuardrailCommand = async (output, context) => {
|
|
99
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
100
|
+
return de_CommandError(output, context);
|
|
101
|
+
}
|
|
102
|
+
const contents = map({
|
|
103
|
+
$metadata: deserializeMetadata(output),
|
|
104
|
+
});
|
|
105
|
+
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
|
|
106
|
+
const doc = take(data, {
|
|
107
|
+
action: __expectString,
|
|
108
|
+
assessments: (_) => de_GuardrailAssessmentList(_, context),
|
|
109
|
+
outputs: _json,
|
|
110
|
+
usage: _json,
|
|
111
|
+
});
|
|
112
|
+
Object.assign(contents, doc);
|
|
113
|
+
return contents;
|
|
114
|
+
};
|
|
82
115
|
export const de_ConverseCommand = async (output, context) => {
|
|
83
116
|
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
84
117
|
return de_CommandError(output, context);
|
|
@@ -92,7 +125,7 @@ export const de_ConverseCommand = async (output, context) => {
|
|
|
92
125
|
metrics: _json,
|
|
93
126
|
output: (_) => de_ConverseOutput(__expectUnion(_), context),
|
|
94
127
|
stopReason: __expectString,
|
|
95
|
-
trace:
|
|
128
|
+
trace: (_) => de_ConverseTrace(_, context),
|
|
96
129
|
usage: _json,
|
|
97
130
|
});
|
|
98
131
|
Object.assign(contents, doc);
|
|
@@ -146,27 +179,27 @@ const de_CommandError = async (output, context) => {
|
|
|
146
179
|
case "InternalServerException":
|
|
147
180
|
case "com.amazonaws.bedrockruntime#InternalServerException":
|
|
148
181
|
throw await de_InternalServerExceptionRes(parsedOutput, context);
|
|
149
|
-
case "ModelErrorException":
|
|
150
|
-
case "com.amazonaws.bedrockruntime#ModelErrorException":
|
|
151
|
-
throw await de_ModelErrorExceptionRes(parsedOutput, context);
|
|
152
|
-
case "ModelNotReadyException":
|
|
153
|
-
case "com.amazonaws.bedrockruntime#ModelNotReadyException":
|
|
154
|
-
throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
|
|
155
|
-
case "ModelTimeoutException":
|
|
156
|
-
case "com.amazonaws.bedrockruntime#ModelTimeoutException":
|
|
157
|
-
throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
|
|
158
182
|
case "ResourceNotFoundException":
|
|
159
183
|
case "com.amazonaws.bedrockruntime#ResourceNotFoundException":
|
|
160
184
|
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
185
|
+
case "ServiceQuotaExceededException":
|
|
186
|
+
case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
|
|
187
|
+
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
161
188
|
case "ThrottlingException":
|
|
162
189
|
case "com.amazonaws.bedrockruntime#ThrottlingException":
|
|
163
190
|
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
164
191
|
case "ValidationException":
|
|
165
192
|
case "com.amazonaws.bedrockruntime#ValidationException":
|
|
166
193
|
throw await de_ValidationExceptionRes(parsedOutput, context);
|
|
167
|
-
case "
|
|
168
|
-
case "com.amazonaws.bedrockruntime#
|
|
169
|
-
throw await
|
|
194
|
+
case "ModelErrorException":
|
|
195
|
+
case "com.amazonaws.bedrockruntime#ModelErrorException":
|
|
196
|
+
throw await de_ModelErrorExceptionRes(parsedOutput, context);
|
|
197
|
+
case "ModelNotReadyException":
|
|
198
|
+
case "com.amazonaws.bedrockruntime#ModelNotReadyException":
|
|
199
|
+
throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
|
|
200
|
+
case "ModelTimeoutException":
|
|
201
|
+
case "com.amazonaws.bedrockruntime#ModelTimeoutException":
|
|
202
|
+
throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
|
|
170
203
|
case "ModelStreamErrorException":
|
|
171
204
|
case "com.amazonaws.bedrockruntime#ModelStreamErrorException":
|
|
172
205
|
throw await de_ModelStreamErrorExceptionRes(parsedOutput, context);
|
|
@@ -425,7 +458,7 @@ const de_ContentBlockStopEvent_event = async (output, context) => {
|
|
|
425
458
|
const de_ConverseStreamMetadataEvent_event = async (output, context) => {
|
|
426
459
|
const contents = {};
|
|
427
460
|
const data = await parseBody(output.body, context);
|
|
428
|
-
Object.assign(contents,
|
|
461
|
+
Object.assign(contents, de_ConverseStreamMetadataEvent(data, context));
|
|
429
462
|
return contents;
|
|
430
463
|
};
|
|
431
464
|
const de_InternalServerException_event = async (output, context) => {
|
|
@@ -657,6 +690,23 @@ const de_ConverseOutput = (output, context) => {
|
|
|
657
690
|
}
|
|
658
691
|
return { $unknown: Object.entries(output)[0] };
|
|
659
692
|
};
|
|
693
|
+
const de_ConverseStreamMetadataEvent = (output, context) => {
|
|
694
|
+
return take(output, {
|
|
695
|
+
metrics: _json,
|
|
696
|
+
trace: (_) => de_ConverseStreamTrace(_, context),
|
|
697
|
+
usage: _json,
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
const de_ConverseStreamTrace = (output, context) => {
|
|
701
|
+
return take(output, {
|
|
702
|
+
guardrail: (_) => de_GuardrailTraceAssessment(_, context),
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
const de_ConverseTrace = (output, context) => {
|
|
706
|
+
return take(output, {
|
|
707
|
+
guardrail: (_) => de_GuardrailTraceAssessment(_, context),
|
|
708
|
+
});
|
|
709
|
+
};
|
|
660
710
|
const de_DocumentBlock = (output, context) => {
|
|
661
711
|
return take(output, {
|
|
662
712
|
format: __expectString,
|
|
@@ -672,6 +722,69 @@ const de_DocumentSource = (output, context) => {
|
|
|
672
722
|
}
|
|
673
723
|
return { $unknown: Object.entries(output)[0] };
|
|
674
724
|
};
|
|
725
|
+
const de_GuardrailAssessment = (output, context) => {
|
|
726
|
+
return take(output, {
|
|
727
|
+
contentPolicy: _json,
|
|
728
|
+
contextualGroundingPolicy: (_) => de_GuardrailContextualGroundingPolicyAssessment(_, context),
|
|
729
|
+
sensitiveInformationPolicy: _json,
|
|
730
|
+
topicPolicy: _json,
|
|
731
|
+
wordPolicy: _json,
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
const de_GuardrailAssessmentList = (output, context) => {
|
|
735
|
+
const retVal = (output || [])
|
|
736
|
+
.filter((e) => e != null)
|
|
737
|
+
.map((entry) => {
|
|
738
|
+
return de_GuardrailAssessment(entry, context);
|
|
739
|
+
});
|
|
740
|
+
return retVal;
|
|
741
|
+
};
|
|
742
|
+
const de_GuardrailAssessmentListMap = (output, context) => {
|
|
743
|
+
return Object.entries(output).reduce((acc, [key, value]) => {
|
|
744
|
+
if (value === null) {
|
|
745
|
+
return acc;
|
|
746
|
+
}
|
|
747
|
+
acc[key] = de_GuardrailAssessmentList(value, context);
|
|
748
|
+
return acc;
|
|
749
|
+
}, {});
|
|
750
|
+
};
|
|
751
|
+
const de_GuardrailAssessmentMap = (output, context) => {
|
|
752
|
+
return Object.entries(output).reduce((acc, [key, value]) => {
|
|
753
|
+
if (value === null) {
|
|
754
|
+
return acc;
|
|
755
|
+
}
|
|
756
|
+
acc[key] = de_GuardrailAssessment(value, context);
|
|
757
|
+
return acc;
|
|
758
|
+
}, {});
|
|
759
|
+
};
|
|
760
|
+
const de_GuardrailContextualGroundingFilter = (output, context) => {
|
|
761
|
+
return take(output, {
|
|
762
|
+
action: __expectString,
|
|
763
|
+
score: __limitedParseDouble,
|
|
764
|
+
threshold: __limitedParseDouble,
|
|
765
|
+
type: __expectString,
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
const de_GuardrailContextualGroundingFilters = (output, context) => {
|
|
769
|
+
const retVal = (output || [])
|
|
770
|
+
.filter((e) => e != null)
|
|
771
|
+
.map((entry) => {
|
|
772
|
+
return de_GuardrailContextualGroundingFilter(entry, context);
|
|
773
|
+
});
|
|
774
|
+
return retVal;
|
|
775
|
+
};
|
|
776
|
+
const de_GuardrailContextualGroundingPolicyAssessment = (output, context) => {
|
|
777
|
+
return take(output, {
|
|
778
|
+
filters: (_) => de_GuardrailContextualGroundingFilters(_, context),
|
|
779
|
+
});
|
|
780
|
+
};
|
|
781
|
+
const de_GuardrailTraceAssessment = (output, context) => {
|
|
782
|
+
return take(output, {
|
|
783
|
+
inputAssessment: (_) => de_GuardrailAssessmentMap(_, context),
|
|
784
|
+
modelOutput: _json,
|
|
785
|
+
outputAssessments: (_) => de_GuardrailAssessmentListMap(_, context),
|
|
786
|
+
});
|
|
787
|
+
};
|
|
675
788
|
const de_ImageBlock = (output, context) => {
|
|
676
789
|
return take(output, {
|
|
677
790
|
format: __expectString,
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
|
|
2
2
|
import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
|
|
3
|
+
import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand";
|
|
3
4
|
import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
|
|
4
5
|
import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
|
|
5
6
|
import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
|
|
6
7
|
import { InvokeModelWithResponseStreamCommandInput, InvokeModelWithResponseStreamCommandOutput } from "./commands/InvokeModelWithResponseStreamCommand";
|
|
7
8
|
export interface BedrockRuntime {
|
|
9
|
+
/**
|
|
10
|
+
* @see {@link ApplyGuardrailCommand}
|
|
11
|
+
*/
|
|
12
|
+
applyGuardrail(args: ApplyGuardrailCommandInput, options?: __HttpHandlerOptions): Promise<ApplyGuardrailCommandOutput>;
|
|
13
|
+
applyGuardrail(args: ApplyGuardrailCommandInput, cb: (err: any, data?: ApplyGuardrailCommandOutput) => void): void;
|
|
14
|
+
applyGuardrail(args: ApplyGuardrailCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: ApplyGuardrailCommandOutput) => void): void;
|
|
8
15
|
/**
|
|
9
16
|
* @see {@link ConverseCommand}
|
|
10
17
|
*/
|
|
@@ -8,6 +8,7 @@ import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol
|
|
|
8
8
|
import { Client as __Client, DefaultsMode as __DefaultsMode, SmithyConfiguration as __SmithyConfiguration, SmithyResolvedConfiguration as __SmithyResolvedConfiguration } from "@smithy/smithy-client";
|
|
9
9
|
import { AwsCredentialIdentityProvider, BodyLengthCalculator as __BodyLengthCalculator, CheckOptionalClientConfig as __CheckOptionalClientConfig, ChecksumConstructor as __ChecksumConstructor, Decoder as __Decoder, Encoder as __Encoder, EventStreamSerdeProvider as __EventStreamSerdeProvider, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, Logger as __Logger, Provider as __Provider, Provider, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent } from "@smithy/types";
|
|
10
10
|
import { HttpAuthSchemeInputConfig, HttpAuthSchemeResolvedConfig } from "./auth/httpAuthSchemeProvider";
|
|
11
|
+
import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand";
|
|
11
12
|
import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
|
|
12
13
|
import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
|
|
13
14
|
import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
|
|
@@ -18,11 +19,11 @@ export { __Client };
|
|
|
18
19
|
/**
|
|
19
20
|
* @public
|
|
20
21
|
*/
|
|
21
|
-
export type ServiceInputTypes = ConverseCommandInput | ConverseStreamCommandInput | InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput;
|
|
22
|
+
export type ServiceInputTypes = ApplyGuardrailCommandInput | ConverseCommandInput | ConverseStreamCommandInput | InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput;
|
|
22
23
|
/**
|
|
23
24
|
* @public
|
|
24
25
|
*/
|
|
25
|
-
export type ServiceOutputTypes = ConverseCommandOutput | ConverseStreamCommandOutput | InvokeModelCommandOutput | InvokeModelWithResponseStreamCommandOutput;
|
|
26
|
+
export type ServiceOutputTypes = ApplyGuardrailCommandOutput | ConverseCommandOutput | ConverseStreamCommandOutput | InvokeModelCommandOutput | InvokeModelWithResponseStreamCommandOutput;
|
|
26
27
|
/**
|
|
27
28
|
* @public
|
|
28
29
|
*/
|
|
@@ -140,7 +141,7 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
|
|
|
140
141
|
/**
|
|
141
142
|
* @public
|
|
142
143
|
*/
|
|
143
|
-
export type BedrockRuntimeClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & ClientDefaults & RegionInputConfig & EndpointInputConfig<EndpointParameters> &
|
|
144
|
+
export type BedrockRuntimeClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & ClientDefaults & RegionInputConfig & EndpointInputConfig<EndpointParameters> & HostHeaderInputConfig & UserAgentInputConfig & RetryInputConfig & EventStreamSerdeInputConfig & HttpAuthSchemeInputConfig & ClientInputEndpointParameters;
|
|
144
145
|
/**
|
|
145
146
|
* @public
|
|
146
147
|
*
|
|
@@ -151,7 +152,7 @@ export interface BedrockRuntimeClientConfig extends BedrockRuntimeClientConfigTy
|
|
|
151
152
|
/**
|
|
152
153
|
* @public
|
|
153
154
|
*/
|
|
154
|
-
export type BedrockRuntimeClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> & Required<ClientDefaults> & RuntimeExtensionsConfig & RegionResolvedConfig & EndpointResolvedConfig<EndpointParameters> &
|
|
155
|
+
export type BedrockRuntimeClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> & Required<ClientDefaults> & RuntimeExtensionsConfig & RegionResolvedConfig & EndpointResolvedConfig<EndpointParameters> & HostHeaderResolvedConfig & UserAgentResolvedConfig & RetryResolvedConfig & EventStreamSerdeResolvedConfig & HttpAuthSchemeResolvedConfig & ClientResolvedEndpointParameters;
|
|
155
156
|
/**
|
|
156
157
|
* @public
|
|
157
158
|
*
|