@aws-sdk/client-bedrock-runtime 3.490.0 → 3.496.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/dist-cjs/index.js CHANGED
@@ -1,11 +1,889 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BedrockRuntimeServiceException = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./BedrockRuntimeClient"), exports);
6
- tslib_1.__exportStar(require("./BedrockRuntime"), exports);
7
- tslib_1.__exportStar(require("./commands"), exports);
8
- tslib_1.__exportStar(require("./models"), exports);
9
- require("@aws-sdk/util-endpoints");
10
- var BedrockRuntimeServiceException_1 = require("./models/BedrockRuntimeServiceException");
11
- Object.defineProperty(exports, "BedrockRuntimeServiceException", { enumerable: true, get: function () { return BedrockRuntimeServiceException_1.BedrockRuntimeServiceException; } });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ AccessDeniedException: () => AccessDeniedException,
25
+ BedrockRuntime: () => BedrockRuntime,
26
+ BedrockRuntimeClient: () => BedrockRuntimeClient,
27
+ BedrockRuntimeServiceException: () => BedrockRuntimeServiceException,
28
+ InternalServerException: () => InternalServerException,
29
+ InvokeModelCommand: () => InvokeModelCommand,
30
+ InvokeModelRequestFilterSensitiveLog: () => InvokeModelRequestFilterSensitiveLog,
31
+ InvokeModelResponseFilterSensitiveLog: () => InvokeModelResponseFilterSensitiveLog,
32
+ InvokeModelWithResponseStreamCommand: () => InvokeModelWithResponseStreamCommand,
33
+ InvokeModelWithResponseStreamRequestFilterSensitiveLog: () => InvokeModelWithResponseStreamRequestFilterSensitiveLog,
34
+ InvokeModelWithResponseStreamResponseFilterSensitiveLog: () => InvokeModelWithResponseStreamResponseFilterSensitiveLog,
35
+ ModelErrorException: () => ModelErrorException,
36
+ ModelNotReadyException: () => ModelNotReadyException,
37
+ ModelStreamErrorException: () => ModelStreamErrorException,
38
+ ModelTimeoutException: () => ModelTimeoutException,
39
+ PayloadPartFilterSensitiveLog: () => PayloadPartFilterSensitiveLog,
40
+ ResourceNotFoundException: () => ResourceNotFoundException,
41
+ ResponseStream: () => ResponseStream,
42
+ ResponseStreamFilterSensitiveLog: () => ResponseStreamFilterSensitiveLog,
43
+ ServiceQuotaExceededException: () => ServiceQuotaExceededException,
44
+ ThrottlingException: () => ThrottlingException,
45
+ ValidationException: () => ValidationException,
46
+ __Client: () => import_smithy_client.Client
47
+ });
48
+ module.exports = __toCommonJS(src_exports);
49
+
50
+ // src/BedrockRuntimeClient.ts
51
+ var import_middleware_host_header = require("@aws-sdk/middleware-host-header");
52
+ var import_middleware_logger = require("@aws-sdk/middleware-logger");
53
+ var import_middleware_recursion_detection = require("@aws-sdk/middleware-recursion-detection");
54
+ var import_middleware_signing = require("@aws-sdk/middleware-signing");
55
+ var import_middleware_user_agent = require("@aws-sdk/middleware-user-agent");
56
+ var import_config_resolver = require("@smithy/config-resolver");
57
+ var import_eventstream_serde_config_resolver = require("@smithy/eventstream-serde-config-resolver");
58
+ var import_middleware_content_length = require("@smithy/middleware-content-length");
59
+ var import_middleware_endpoint = require("@smithy/middleware-endpoint");
60
+ var import_middleware_retry = require("@smithy/middleware-retry");
61
+
62
+
63
+ // src/endpoint/EndpointParameters.ts
64
+ var resolveClientEndpointParameters = /* @__PURE__ */ __name((options) => {
65
+ return {
66
+ ...options,
67
+ useDualstackEndpoint: options.useDualstackEndpoint ?? false,
68
+ useFipsEndpoint: options.useFipsEndpoint ?? false,
69
+ defaultSigningName: "bedrock"
70
+ };
71
+ }, "resolveClientEndpointParameters");
72
+ var commonParams = {
73
+ UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
74
+ Endpoint: { type: "builtInParams", name: "endpoint" },
75
+ Region: { type: "builtInParams", name: "region" },
76
+ UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
77
+ };
78
+
79
+ // src/BedrockRuntimeClient.ts
80
+ var import_runtimeConfig = require("././runtimeConfig");
81
+
82
+ // src/runtimeExtensions.ts
83
+ var import_region_config_resolver = require("@aws-sdk/region-config-resolver");
84
+ var import_protocol_http = require("@smithy/protocol-http");
85
+ var import_smithy_client = require("@smithy/smithy-client");
86
+ var asPartial = /* @__PURE__ */ __name((t) => t, "asPartial");
87
+ var resolveRuntimeExtensions = /* @__PURE__ */ __name((runtimeConfig, extensions) => {
88
+ const extensionConfiguration = {
89
+ ...asPartial((0, import_region_config_resolver.getAwsRegionExtensionConfiguration)(runtimeConfig)),
90
+ ...asPartial((0, import_smithy_client.getDefaultExtensionConfiguration)(runtimeConfig)),
91
+ ...asPartial((0, import_protocol_http.getHttpHandlerExtensionConfiguration)(runtimeConfig))
92
+ };
93
+ extensions.forEach((extension) => extension.configure(extensionConfiguration));
94
+ return {
95
+ ...runtimeConfig,
96
+ ...(0, import_region_config_resolver.resolveAwsRegionExtensionConfiguration)(extensionConfiguration),
97
+ ...(0, import_smithy_client.resolveDefaultRuntimeConfig)(extensionConfiguration),
98
+ ...(0, import_protocol_http.resolveHttpHandlerRuntimeConfig)(extensionConfiguration)
99
+ };
100
+ }, "resolveRuntimeExtensions");
101
+
102
+ // src/BedrockRuntimeClient.ts
103
+ var _BedrockRuntimeClient = class _BedrockRuntimeClient extends import_smithy_client.Client {
104
+ constructor(...[configuration]) {
105
+ const _config_0 = (0, import_runtimeConfig.getRuntimeConfig)(configuration || {});
106
+ const _config_1 = resolveClientEndpointParameters(_config_0);
107
+ const _config_2 = (0, import_config_resolver.resolveRegionConfig)(_config_1);
108
+ const _config_3 = (0, import_middleware_endpoint.resolveEndpointConfig)(_config_2);
109
+ const _config_4 = (0, import_middleware_retry.resolveRetryConfig)(_config_3);
110
+ const _config_5 = (0, import_middleware_host_header.resolveHostHeaderConfig)(_config_4);
111
+ const _config_6 = (0, import_middleware_signing.resolveAwsAuthConfig)(_config_5);
112
+ const _config_7 = (0, import_middleware_user_agent.resolveUserAgentConfig)(_config_6);
113
+ const _config_8 = (0, import_eventstream_serde_config_resolver.resolveEventStreamSerdeConfig)(_config_7);
114
+ const _config_9 = resolveRuntimeExtensions(_config_8, (configuration == null ? void 0 : configuration.extensions) || []);
115
+ super(_config_9);
116
+ this.config = _config_9;
117
+ this.middlewareStack.use((0, import_middleware_retry.getRetryPlugin)(this.config));
118
+ this.middlewareStack.use((0, import_middleware_content_length.getContentLengthPlugin)(this.config));
119
+ this.middlewareStack.use((0, import_middleware_host_header.getHostHeaderPlugin)(this.config));
120
+ this.middlewareStack.use((0, import_middleware_logger.getLoggerPlugin)(this.config));
121
+ this.middlewareStack.use((0, import_middleware_recursion_detection.getRecursionDetectionPlugin)(this.config));
122
+ this.middlewareStack.use((0, import_middleware_signing.getAwsAuthPlugin)(this.config));
123
+ this.middlewareStack.use((0, import_middleware_user_agent.getUserAgentPlugin)(this.config));
124
+ }
125
+ /**
126
+ * Destroy underlying resources, like sockets. It's usually not necessary to do this.
127
+ * However in Node.js, it's best to explicitly shut down the client's agent when it is no longer needed.
128
+ * Otherwise, sockets might stay open for quite a long time before the server terminates them.
129
+ */
130
+ destroy() {
131
+ super.destroy();
132
+ }
133
+ };
134
+ __name(_BedrockRuntimeClient, "BedrockRuntimeClient");
135
+ var BedrockRuntimeClient = _BedrockRuntimeClient;
136
+
137
+ // src/BedrockRuntime.ts
138
+
139
+
140
+ // src/commands/InvokeModelCommand.ts
141
+
142
+ var import_middleware_serde = require("@smithy/middleware-serde");
143
+
144
+ var import_types = require("@smithy/types");
145
+
146
+ // src/models/models_0.ts
147
+
148
+
149
+ // src/models/BedrockRuntimeServiceException.ts
150
+
151
+ var _BedrockRuntimeServiceException = class _BedrockRuntimeServiceException extends import_smithy_client.ServiceException {
152
+ /**
153
+ * @internal
154
+ */
155
+ constructor(options) {
156
+ super(options);
157
+ Object.setPrototypeOf(this, _BedrockRuntimeServiceException.prototype);
158
+ }
159
+ };
160
+ __name(_BedrockRuntimeServiceException, "BedrockRuntimeServiceException");
161
+ var BedrockRuntimeServiceException = _BedrockRuntimeServiceException;
162
+
163
+ // src/models/models_0.ts
164
+ var _AccessDeniedException = class _AccessDeniedException extends BedrockRuntimeServiceException {
165
+ /**
166
+ * @internal
167
+ */
168
+ constructor(opts) {
169
+ super({
170
+ name: "AccessDeniedException",
171
+ $fault: "client",
172
+ ...opts
173
+ });
174
+ this.name = "AccessDeniedException";
175
+ this.$fault = "client";
176
+ Object.setPrototypeOf(this, _AccessDeniedException.prototype);
177
+ }
178
+ };
179
+ __name(_AccessDeniedException, "AccessDeniedException");
180
+ var AccessDeniedException = _AccessDeniedException;
181
+ var _InternalServerException = class _InternalServerException extends BedrockRuntimeServiceException {
182
+ /**
183
+ * @internal
184
+ */
185
+ constructor(opts) {
186
+ super({
187
+ name: "InternalServerException",
188
+ $fault: "server",
189
+ ...opts
190
+ });
191
+ this.name = "InternalServerException";
192
+ this.$fault = "server";
193
+ Object.setPrototypeOf(this, _InternalServerException.prototype);
194
+ }
195
+ };
196
+ __name(_InternalServerException, "InternalServerException");
197
+ var InternalServerException = _InternalServerException;
198
+ var _ModelErrorException = class _ModelErrorException extends BedrockRuntimeServiceException {
199
+ /**
200
+ * @internal
201
+ */
202
+ constructor(opts) {
203
+ super({
204
+ name: "ModelErrorException",
205
+ $fault: "client",
206
+ ...opts
207
+ });
208
+ this.name = "ModelErrorException";
209
+ this.$fault = "client";
210
+ Object.setPrototypeOf(this, _ModelErrorException.prototype);
211
+ this.originalStatusCode = opts.originalStatusCode;
212
+ this.resourceName = opts.resourceName;
213
+ }
214
+ };
215
+ __name(_ModelErrorException, "ModelErrorException");
216
+ var ModelErrorException = _ModelErrorException;
217
+ var _ModelNotReadyException = class _ModelNotReadyException extends BedrockRuntimeServiceException {
218
+ /**
219
+ * @internal
220
+ */
221
+ constructor(opts) {
222
+ super({
223
+ name: "ModelNotReadyException",
224
+ $fault: "client",
225
+ ...opts
226
+ });
227
+ this.name = "ModelNotReadyException";
228
+ this.$fault = "client";
229
+ Object.setPrototypeOf(this, _ModelNotReadyException.prototype);
230
+ }
231
+ };
232
+ __name(_ModelNotReadyException, "ModelNotReadyException");
233
+ var ModelNotReadyException = _ModelNotReadyException;
234
+ var _ModelTimeoutException = class _ModelTimeoutException extends BedrockRuntimeServiceException {
235
+ /**
236
+ * @internal
237
+ */
238
+ constructor(opts) {
239
+ super({
240
+ name: "ModelTimeoutException",
241
+ $fault: "client",
242
+ ...opts
243
+ });
244
+ this.name = "ModelTimeoutException";
245
+ this.$fault = "client";
246
+ Object.setPrototypeOf(this, _ModelTimeoutException.prototype);
247
+ }
248
+ };
249
+ __name(_ModelTimeoutException, "ModelTimeoutException");
250
+ var ModelTimeoutException = _ModelTimeoutException;
251
+ var _ResourceNotFoundException = class _ResourceNotFoundException extends BedrockRuntimeServiceException {
252
+ /**
253
+ * @internal
254
+ */
255
+ constructor(opts) {
256
+ super({
257
+ name: "ResourceNotFoundException",
258
+ $fault: "client",
259
+ ...opts
260
+ });
261
+ this.name = "ResourceNotFoundException";
262
+ this.$fault = "client";
263
+ Object.setPrototypeOf(this, _ResourceNotFoundException.prototype);
264
+ }
265
+ };
266
+ __name(_ResourceNotFoundException, "ResourceNotFoundException");
267
+ var ResourceNotFoundException = _ResourceNotFoundException;
268
+ var _ServiceQuotaExceededException = class _ServiceQuotaExceededException extends BedrockRuntimeServiceException {
269
+ /**
270
+ * @internal
271
+ */
272
+ constructor(opts) {
273
+ super({
274
+ name: "ServiceQuotaExceededException",
275
+ $fault: "client",
276
+ ...opts
277
+ });
278
+ this.name = "ServiceQuotaExceededException";
279
+ this.$fault = "client";
280
+ Object.setPrototypeOf(this, _ServiceQuotaExceededException.prototype);
281
+ }
282
+ };
283
+ __name(_ServiceQuotaExceededException, "ServiceQuotaExceededException");
284
+ var ServiceQuotaExceededException = _ServiceQuotaExceededException;
285
+ var _ThrottlingException = class _ThrottlingException extends BedrockRuntimeServiceException {
286
+ /**
287
+ * @internal
288
+ */
289
+ constructor(opts) {
290
+ super({
291
+ name: "ThrottlingException",
292
+ $fault: "client",
293
+ ...opts
294
+ });
295
+ this.name = "ThrottlingException";
296
+ this.$fault = "client";
297
+ Object.setPrototypeOf(this, _ThrottlingException.prototype);
298
+ }
299
+ };
300
+ __name(_ThrottlingException, "ThrottlingException");
301
+ var ThrottlingException = _ThrottlingException;
302
+ var _ValidationException = class _ValidationException extends BedrockRuntimeServiceException {
303
+ /**
304
+ * @internal
305
+ */
306
+ constructor(opts) {
307
+ super({
308
+ name: "ValidationException",
309
+ $fault: "client",
310
+ ...opts
311
+ });
312
+ this.name = "ValidationException";
313
+ this.$fault = "client";
314
+ Object.setPrototypeOf(this, _ValidationException.prototype);
315
+ }
316
+ };
317
+ __name(_ValidationException, "ValidationException");
318
+ var ValidationException = _ValidationException;
319
+ var _ModelStreamErrorException = class _ModelStreamErrorException extends BedrockRuntimeServiceException {
320
+ /**
321
+ * @internal
322
+ */
323
+ constructor(opts) {
324
+ super({
325
+ name: "ModelStreamErrorException",
326
+ $fault: "client",
327
+ ...opts
328
+ });
329
+ this.name = "ModelStreamErrorException";
330
+ this.$fault = "client";
331
+ Object.setPrototypeOf(this, _ModelStreamErrorException.prototype);
332
+ this.originalStatusCode = opts.originalStatusCode;
333
+ this.originalMessage = opts.originalMessage;
334
+ }
335
+ };
336
+ __name(_ModelStreamErrorException, "ModelStreamErrorException");
337
+ var ModelStreamErrorException = _ModelStreamErrorException;
338
+ var ResponseStream;
339
+ ((ResponseStream3) => {
340
+ ResponseStream3.visit = /* @__PURE__ */ __name((value, visitor) => {
341
+ if (value.chunk !== void 0)
342
+ return visitor.chunk(value.chunk);
343
+ if (value.internalServerException !== void 0)
344
+ return visitor.internalServerException(value.internalServerException);
345
+ if (value.modelStreamErrorException !== void 0)
346
+ return visitor.modelStreamErrorException(value.modelStreamErrorException);
347
+ if (value.validationException !== void 0)
348
+ return visitor.validationException(value.validationException);
349
+ if (value.throttlingException !== void 0)
350
+ return visitor.throttlingException(value.throttlingException);
351
+ if (value.modelTimeoutException !== void 0)
352
+ return visitor.modelTimeoutException(value.modelTimeoutException);
353
+ return visitor._(value.$unknown[0], value.$unknown[1]);
354
+ }, "visit");
355
+ })(ResponseStream || (ResponseStream = {}));
356
+ var InvokeModelRequestFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
357
+ ...obj,
358
+ ...obj.body && { body: import_smithy_client.SENSITIVE_STRING }
359
+ }), "InvokeModelRequestFilterSensitiveLog");
360
+ var InvokeModelResponseFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
361
+ ...obj,
362
+ ...obj.body && { body: import_smithy_client.SENSITIVE_STRING }
363
+ }), "InvokeModelResponseFilterSensitiveLog");
364
+ var InvokeModelWithResponseStreamRequestFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
365
+ ...obj,
366
+ ...obj.body && { body: import_smithy_client.SENSITIVE_STRING }
367
+ }), "InvokeModelWithResponseStreamRequestFilterSensitiveLog");
368
+ var PayloadPartFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
369
+ ...obj,
370
+ ...obj.bytes && { bytes: import_smithy_client.SENSITIVE_STRING }
371
+ }), "PayloadPartFilterSensitiveLog");
372
+ var ResponseStreamFilterSensitiveLog = /* @__PURE__ */ __name((obj) => {
373
+ if (obj.chunk !== void 0)
374
+ return { chunk: import_smithy_client.SENSITIVE_STRING };
375
+ if (obj.internalServerException !== void 0)
376
+ return { internalServerException: obj.internalServerException };
377
+ if (obj.modelStreamErrorException !== void 0)
378
+ return { modelStreamErrorException: obj.modelStreamErrorException };
379
+ if (obj.validationException !== void 0)
380
+ return { validationException: obj.validationException };
381
+ if (obj.throttlingException !== void 0)
382
+ return { throttlingException: obj.throttlingException };
383
+ if (obj.modelTimeoutException !== void 0)
384
+ return { modelTimeoutException: obj.modelTimeoutException };
385
+ if (obj.$unknown !== void 0)
386
+ return { [obj.$unknown[0]]: "UNKNOWN" };
387
+ }, "ResponseStreamFilterSensitiveLog");
388
+ var InvokeModelWithResponseStreamResponseFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
389
+ ...obj,
390
+ ...obj.body && { body: "STREAMING_CONTENT" }
391
+ }), "InvokeModelWithResponseStreamResponseFilterSensitiveLog");
392
+
393
+ // src/protocols/Aws_restJson1.ts
394
+ var import_core = require("@smithy/core");
395
+
396
+ var se_InvokeModelCommand = /* @__PURE__ */ __name(async (input, context) => {
397
+ const b = (0, import_core.requestBuilder)(input, context);
398
+ const headers = (0, import_smithy_client.map)({}, isSerializableHeaderValue, {
399
+ [_ct]: input[_cT] || "application/octet-stream",
400
+ [_a]: input[_a]
401
+ });
402
+ b.bp("/model/{modelId}/invoke");
403
+ b.p("modelId", () => input.modelId, "{modelId}", false);
404
+ let body;
405
+ if (input.body !== void 0) {
406
+ body = input.body;
407
+ }
408
+ b.m("POST").h(headers).b(body);
409
+ return b.build();
410
+ }, "se_InvokeModelCommand");
411
+ var se_InvokeModelWithResponseStreamCommand = /* @__PURE__ */ __name(async (input, context) => {
412
+ const b = (0, import_core.requestBuilder)(input, context);
413
+ const headers = (0, import_smithy_client.map)({}, isSerializableHeaderValue, {
414
+ [_ct]: input[_cT] || "application/octet-stream",
415
+ [_xaba]: input[_a]
416
+ });
417
+ b.bp("/model/{modelId}/invoke-with-response-stream");
418
+ b.p("modelId", () => input.modelId, "{modelId}", false);
419
+ let body;
420
+ if (input.body !== void 0) {
421
+ body = input.body;
422
+ }
423
+ b.m("POST").h(headers).b(body);
424
+ return b.build();
425
+ }, "se_InvokeModelWithResponseStreamCommand");
426
+ var de_InvokeModelCommand = /* @__PURE__ */ __name(async (output, context) => {
427
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
428
+ return de_InvokeModelCommandError(output, context);
429
+ }
430
+ const contents = (0, import_smithy_client.map)({
431
+ $metadata: deserializeMetadata(output),
432
+ [_cT]: [, output.headers[_ct]]
433
+ });
434
+ const data = await (0, import_smithy_client.collectBody)(output.body, context);
435
+ contents.body = data;
436
+ return contents;
437
+ }, "de_InvokeModelCommand");
438
+ var de_InvokeModelCommandError = /* @__PURE__ */ __name(async (output, context) => {
439
+ const parsedOutput = {
440
+ ...output,
441
+ body: await parseErrorBody(output.body, context)
442
+ };
443
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
444
+ switch (errorCode) {
445
+ case "AccessDeniedException":
446
+ case "com.amazonaws.bedrockruntime#AccessDeniedException":
447
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context);
448
+ case "InternalServerException":
449
+ case "com.amazonaws.bedrockruntime#InternalServerException":
450
+ throw await de_InternalServerExceptionRes(parsedOutput, context);
451
+ case "ModelErrorException":
452
+ case "com.amazonaws.bedrockruntime#ModelErrorException":
453
+ throw await de_ModelErrorExceptionRes(parsedOutput, context);
454
+ case "ModelNotReadyException":
455
+ case "com.amazonaws.bedrockruntime#ModelNotReadyException":
456
+ throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
457
+ case "ModelTimeoutException":
458
+ case "com.amazonaws.bedrockruntime#ModelTimeoutException":
459
+ throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
460
+ case "ResourceNotFoundException":
461
+ case "com.amazonaws.bedrockruntime#ResourceNotFoundException":
462
+ throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
463
+ case "ServiceQuotaExceededException":
464
+ case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
465
+ throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
466
+ case "ThrottlingException":
467
+ case "com.amazonaws.bedrockruntime#ThrottlingException":
468
+ throw await de_ThrottlingExceptionRes(parsedOutput, context);
469
+ case "ValidationException":
470
+ case "com.amazonaws.bedrockruntime#ValidationException":
471
+ throw await de_ValidationExceptionRes(parsedOutput, context);
472
+ default:
473
+ const parsedBody = parsedOutput.body;
474
+ return throwDefaultError({
475
+ output,
476
+ parsedBody,
477
+ errorCode
478
+ });
479
+ }
480
+ }, "de_InvokeModelCommandError");
481
+ var de_InvokeModelWithResponseStreamCommand = /* @__PURE__ */ __name(async (output, context) => {
482
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
483
+ return de_InvokeModelWithResponseStreamCommandError(output, context);
484
+ }
485
+ const contents = (0, import_smithy_client.map)({
486
+ $metadata: deserializeMetadata(output),
487
+ [_cT]: [, output.headers[_xabct]]
488
+ });
489
+ const data = output.body;
490
+ contents.body = de_ResponseStream(data, context);
491
+ return contents;
492
+ }, "de_InvokeModelWithResponseStreamCommand");
493
+ var de_InvokeModelWithResponseStreamCommandError = /* @__PURE__ */ __name(async (output, context) => {
494
+ const parsedOutput = {
495
+ ...output,
496
+ body: await parseErrorBody(output.body, context)
497
+ };
498
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
499
+ switch (errorCode) {
500
+ case "AccessDeniedException":
501
+ case "com.amazonaws.bedrockruntime#AccessDeniedException":
502
+ throw await de_AccessDeniedExceptionRes(parsedOutput, context);
503
+ case "InternalServerException":
504
+ case "com.amazonaws.bedrockruntime#InternalServerException":
505
+ throw await de_InternalServerExceptionRes(parsedOutput, context);
506
+ case "ModelErrorException":
507
+ case "com.amazonaws.bedrockruntime#ModelErrorException":
508
+ throw await de_ModelErrorExceptionRes(parsedOutput, context);
509
+ case "ModelNotReadyException":
510
+ case "com.amazonaws.bedrockruntime#ModelNotReadyException":
511
+ throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
512
+ case "ModelStreamErrorException":
513
+ case "com.amazonaws.bedrockruntime#ModelStreamErrorException":
514
+ throw await de_ModelStreamErrorExceptionRes(parsedOutput, context);
515
+ case "ModelTimeoutException":
516
+ case "com.amazonaws.bedrockruntime#ModelTimeoutException":
517
+ throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
518
+ case "ResourceNotFoundException":
519
+ case "com.amazonaws.bedrockruntime#ResourceNotFoundException":
520
+ throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
521
+ case "ServiceQuotaExceededException":
522
+ case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
523
+ throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
524
+ case "ThrottlingException":
525
+ case "com.amazonaws.bedrockruntime#ThrottlingException":
526
+ throw await de_ThrottlingExceptionRes(parsedOutput, context);
527
+ case "ValidationException":
528
+ case "com.amazonaws.bedrockruntime#ValidationException":
529
+ throw await de_ValidationExceptionRes(parsedOutput, context);
530
+ default:
531
+ const parsedBody = parsedOutput.body;
532
+ return throwDefaultError({
533
+ output,
534
+ parsedBody,
535
+ errorCode
536
+ });
537
+ }
538
+ }, "de_InvokeModelWithResponseStreamCommandError");
539
+ var throwDefaultError = (0, import_smithy_client.withBaseException)(BedrockRuntimeServiceException);
540
+ var de_AccessDeniedExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
541
+ const contents = (0, import_smithy_client.map)({});
542
+ const data = parsedOutput.body;
543
+ const doc = (0, import_smithy_client.take)(data, {
544
+ message: import_smithy_client.expectString
545
+ });
546
+ Object.assign(contents, doc);
547
+ const exception = new AccessDeniedException({
548
+ $metadata: deserializeMetadata(parsedOutput),
549
+ ...contents
550
+ });
551
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
552
+ }, "de_AccessDeniedExceptionRes");
553
+ var de_InternalServerExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
554
+ const contents = (0, import_smithy_client.map)({});
555
+ const data = parsedOutput.body;
556
+ const doc = (0, import_smithy_client.take)(data, {
557
+ message: import_smithy_client.expectString
558
+ });
559
+ Object.assign(contents, doc);
560
+ const exception = new InternalServerException({
561
+ $metadata: deserializeMetadata(parsedOutput),
562
+ ...contents
563
+ });
564
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
565
+ }, "de_InternalServerExceptionRes");
566
+ var de_ModelErrorExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
567
+ const contents = (0, import_smithy_client.map)({});
568
+ const data = parsedOutput.body;
569
+ const doc = (0, import_smithy_client.take)(data, {
570
+ message: import_smithy_client.expectString,
571
+ originalStatusCode: import_smithy_client.expectInt32,
572
+ resourceName: import_smithy_client.expectString
573
+ });
574
+ Object.assign(contents, doc);
575
+ const exception = new ModelErrorException({
576
+ $metadata: deserializeMetadata(parsedOutput),
577
+ ...contents
578
+ });
579
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
580
+ }, "de_ModelErrorExceptionRes");
581
+ var de_ModelNotReadyExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
582
+ const contents = (0, import_smithy_client.map)({});
583
+ const data = parsedOutput.body;
584
+ const doc = (0, import_smithy_client.take)(data, {
585
+ message: import_smithy_client.expectString
586
+ });
587
+ Object.assign(contents, doc);
588
+ const exception = new ModelNotReadyException({
589
+ $metadata: deserializeMetadata(parsedOutput),
590
+ ...contents
591
+ });
592
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
593
+ }, "de_ModelNotReadyExceptionRes");
594
+ var de_ModelStreamErrorExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
595
+ const contents = (0, import_smithy_client.map)({});
596
+ const data = parsedOutput.body;
597
+ const doc = (0, import_smithy_client.take)(data, {
598
+ message: import_smithy_client.expectString,
599
+ originalMessage: import_smithy_client.expectString,
600
+ originalStatusCode: import_smithy_client.expectInt32
601
+ });
602
+ Object.assign(contents, doc);
603
+ const exception = new ModelStreamErrorException({
604
+ $metadata: deserializeMetadata(parsedOutput),
605
+ ...contents
606
+ });
607
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
608
+ }, "de_ModelStreamErrorExceptionRes");
609
+ var de_ModelTimeoutExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
610
+ const contents = (0, import_smithy_client.map)({});
611
+ const data = parsedOutput.body;
612
+ const doc = (0, import_smithy_client.take)(data, {
613
+ message: import_smithy_client.expectString
614
+ });
615
+ Object.assign(contents, doc);
616
+ const exception = new ModelTimeoutException({
617
+ $metadata: deserializeMetadata(parsedOutput),
618
+ ...contents
619
+ });
620
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
621
+ }, "de_ModelTimeoutExceptionRes");
622
+ var de_ResourceNotFoundExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
623
+ const contents = (0, import_smithy_client.map)({});
624
+ const data = parsedOutput.body;
625
+ const doc = (0, import_smithy_client.take)(data, {
626
+ message: import_smithy_client.expectString
627
+ });
628
+ Object.assign(contents, doc);
629
+ const exception = new ResourceNotFoundException({
630
+ $metadata: deserializeMetadata(parsedOutput),
631
+ ...contents
632
+ });
633
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
634
+ }, "de_ResourceNotFoundExceptionRes");
635
+ var de_ServiceQuotaExceededExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
636
+ const contents = (0, import_smithy_client.map)({});
637
+ const data = parsedOutput.body;
638
+ const doc = (0, import_smithy_client.take)(data, {
639
+ message: import_smithy_client.expectString
640
+ });
641
+ Object.assign(contents, doc);
642
+ const exception = new ServiceQuotaExceededException({
643
+ $metadata: deserializeMetadata(parsedOutput),
644
+ ...contents
645
+ });
646
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
647
+ }, "de_ServiceQuotaExceededExceptionRes");
648
+ var de_ThrottlingExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
649
+ const contents = (0, import_smithy_client.map)({});
650
+ const data = parsedOutput.body;
651
+ const doc = (0, import_smithy_client.take)(data, {
652
+ message: import_smithy_client.expectString
653
+ });
654
+ Object.assign(contents, doc);
655
+ const exception = new ThrottlingException({
656
+ $metadata: deserializeMetadata(parsedOutput),
657
+ ...contents
658
+ });
659
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
660
+ }, "de_ThrottlingExceptionRes");
661
+ var de_ValidationExceptionRes = /* @__PURE__ */ __name(async (parsedOutput, context) => {
662
+ const contents = (0, import_smithy_client.map)({});
663
+ const data = parsedOutput.body;
664
+ const doc = (0, import_smithy_client.take)(data, {
665
+ message: import_smithy_client.expectString
666
+ });
667
+ Object.assign(contents, doc);
668
+ const exception = new ValidationException({
669
+ $metadata: deserializeMetadata(parsedOutput),
670
+ ...contents
671
+ });
672
+ return (0, import_smithy_client.decorateServiceException)(exception, parsedOutput.body);
673
+ }, "de_ValidationExceptionRes");
674
+ var de_ResponseStream = /* @__PURE__ */ __name((output, context) => {
675
+ return context.eventStreamMarshaller.deserialize(output, async (event) => {
676
+ if (event["chunk"] != null) {
677
+ return {
678
+ chunk: await de_PayloadPart_event(event["chunk"], context)
679
+ };
680
+ }
681
+ if (event["internalServerException"] != null) {
682
+ return {
683
+ internalServerException: await de_InternalServerException_event(event["internalServerException"], context)
684
+ };
685
+ }
686
+ if (event["modelStreamErrorException"] != null) {
687
+ return {
688
+ modelStreamErrorException: await de_ModelStreamErrorException_event(
689
+ event["modelStreamErrorException"],
690
+ context
691
+ )
692
+ };
693
+ }
694
+ if (event["validationException"] != null) {
695
+ return {
696
+ validationException: await de_ValidationException_event(event["validationException"], context)
697
+ };
698
+ }
699
+ if (event["throttlingException"] != null) {
700
+ return {
701
+ throttlingException: await de_ThrottlingException_event(event["throttlingException"], context)
702
+ };
703
+ }
704
+ if (event["modelTimeoutException"] != null) {
705
+ return {
706
+ modelTimeoutException: await de_ModelTimeoutException_event(event["modelTimeoutException"], context)
707
+ };
708
+ }
709
+ return { $unknown: output };
710
+ });
711
+ }, "de_ResponseStream");
712
+ var de_InternalServerException_event = /* @__PURE__ */ __name(async (output, context) => {
713
+ const parsedOutput = {
714
+ ...output,
715
+ body: await parseBody(output.body, context)
716
+ };
717
+ return de_InternalServerExceptionRes(parsedOutput, context);
718
+ }, "de_InternalServerException_event");
719
+ var de_ModelStreamErrorException_event = /* @__PURE__ */ __name(async (output, context) => {
720
+ const parsedOutput = {
721
+ ...output,
722
+ body: await parseBody(output.body, context)
723
+ };
724
+ return de_ModelStreamErrorExceptionRes(parsedOutput, context);
725
+ }, "de_ModelStreamErrorException_event");
726
+ var de_ModelTimeoutException_event = /* @__PURE__ */ __name(async (output, context) => {
727
+ const parsedOutput = {
728
+ ...output,
729
+ body: await parseBody(output.body, context)
730
+ };
731
+ return de_ModelTimeoutExceptionRes(parsedOutput, context);
732
+ }, "de_ModelTimeoutException_event");
733
+ var de_PayloadPart_event = /* @__PURE__ */ __name(async (output, context) => {
734
+ const contents = {};
735
+ const data = await parseBody(output.body, context);
736
+ Object.assign(contents, de_PayloadPart(data, context));
737
+ return contents;
738
+ }, "de_PayloadPart_event");
739
+ var de_ThrottlingException_event = /* @__PURE__ */ __name(async (output, context) => {
740
+ const parsedOutput = {
741
+ ...output,
742
+ body: await parseBody(output.body, context)
743
+ };
744
+ return de_ThrottlingExceptionRes(parsedOutput, context);
745
+ }, "de_ThrottlingException_event");
746
+ var de_ValidationException_event = /* @__PURE__ */ __name(async (output, context) => {
747
+ const parsedOutput = {
748
+ ...output,
749
+ body: await parseBody(output.body, context)
750
+ };
751
+ return de_ValidationExceptionRes(parsedOutput, context);
752
+ }, "de_ValidationException_event");
753
+ var de_PayloadPart = /* @__PURE__ */ __name((output, context) => {
754
+ return (0, import_smithy_client.take)(output, {
755
+ bytes: context.base64Decoder
756
+ });
757
+ }, "de_PayloadPart");
758
+ var deserializeMetadata = /* @__PURE__ */ __name((output) => ({
759
+ httpStatusCode: output.statusCode,
760
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
761
+ extendedRequestId: output.headers["x-amz-id-2"],
762
+ cfId: output.headers["x-amz-cf-id"]
763
+ }), "deserializeMetadata");
764
+ var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), "collectBodyString");
765
+ var isSerializableHeaderValue = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null && value !== "" && (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) && (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0), "isSerializableHeaderValue");
766
+ var _a = "accept";
767
+ var _cT = "contentType";
768
+ var _ct = "content-type";
769
+ var _xaba = "x-amzn-bedrock-accept";
770
+ var _xabct = "x-amzn-bedrock-content-type";
771
+ var parseBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
772
+ if (encoded.length) {
773
+ return JSON.parse(encoded);
774
+ }
775
+ return {};
776
+ }), "parseBody");
777
+ var parseErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => {
778
+ const value = await parseBody(errorBody, context);
779
+ value.message = value.message ?? value.Message;
780
+ return value;
781
+ }, "parseErrorBody");
782
+ var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => {
783
+ const findKey = /* @__PURE__ */ __name((object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()), "findKey");
784
+ const sanitizeErrorCode = /* @__PURE__ */ __name((rawValue) => {
785
+ let cleanValue = rawValue;
786
+ if (typeof cleanValue === "number") {
787
+ cleanValue = cleanValue.toString();
788
+ }
789
+ if (cleanValue.indexOf(",") >= 0) {
790
+ cleanValue = cleanValue.split(",")[0];
791
+ }
792
+ if (cleanValue.indexOf(":") >= 0) {
793
+ cleanValue = cleanValue.split(":")[0];
794
+ }
795
+ if (cleanValue.indexOf("#") >= 0) {
796
+ cleanValue = cleanValue.split("#")[1];
797
+ }
798
+ return cleanValue;
799
+ }, "sanitizeErrorCode");
800
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
801
+ if (headerKey !== void 0) {
802
+ return sanitizeErrorCode(output.headers[headerKey]);
803
+ }
804
+ if (data.code !== void 0) {
805
+ return sanitizeErrorCode(data.code);
806
+ }
807
+ if (data["__type"] !== void 0) {
808
+ return sanitizeErrorCode(data["__type"]);
809
+ }
810
+ }, "loadRestJsonErrorCode");
811
+
812
+ // src/commands/InvokeModelCommand.ts
813
+ var _InvokeModelCommand = class _InvokeModelCommand extends import_smithy_client.Command.classBuilder().ep({
814
+ ...commonParams
815
+ }).m(function(Command, cs, config, o) {
816
+ return [
817
+ (0, import_middleware_serde.getSerdePlugin)(config, this.serialize, this.deserialize),
818
+ (0, import_middleware_endpoint.getEndpointPlugin)(config, Command.getEndpointParameterInstructions())
819
+ ];
820
+ }).s("AmazonBedrockFrontendService", "InvokeModel", {}).n("BedrockRuntimeClient", "InvokeModelCommand").f(InvokeModelRequestFilterSensitiveLog, InvokeModelResponseFilterSensitiveLog).ser(se_InvokeModelCommand).de(de_InvokeModelCommand).build() {
821
+ };
822
+ __name(_InvokeModelCommand, "InvokeModelCommand");
823
+ var InvokeModelCommand = _InvokeModelCommand;
824
+
825
+ // src/commands/InvokeModelWithResponseStreamCommand.ts
826
+
827
+
828
+
829
+
830
+ var _InvokeModelWithResponseStreamCommand = class _InvokeModelWithResponseStreamCommand extends import_smithy_client.Command.classBuilder().ep({
831
+ ...commonParams
832
+ }).m(function(Command, cs, config, o) {
833
+ return [
834
+ (0, import_middleware_serde.getSerdePlugin)(config, this.serialize, this.deserialize),
835
+ (0, import_middleware_endpoint.getEndpointPlugin)(config, Command.getEndpointParameterInstructions())
836
+ ];
837
+ }).s("AmazonBedrockFrontendService", "InvokeModelWithResponseStream", {
838
+ /**
839
+ * @internal
840
+ */
841
+ eventStream: {
842
+ output: true
843
+ }
844
+ }).n("BedrockRuntimeClient", "InvokeModelWithResponseStreamCommand").f(InvokeModelWithResponseStreamRequestFilterSensitiveLog, InvokeModelWithResponseStreamResponseFilterSensitiveLog).ser(se_InvokeModelWithResponseStreamCommand).de(de_InvokeModelWithResponseStreamCommand).build() {
845
+ };
846
+ __name(_InvokeModelWithResponseStreamCommand, "InvokeModelWithResponseStreamCommand");
847
+ var InvokeModelWithResponseStreamCommand = _InvokeModelWithResponseStreamCommand;
848
+
849
+ // src/BedrockRuntime.ts
850
+ var commands = {
851
+ InvokeModelCommand,
852
+ InvokeModelWithResponseStreamCommand
853
+ };
854
+ var _BedrockRuntime = class _BedrockRuntime extends BedrockRuntimeClient {
855
+ };
856
+ __name(_BedrockRuntime, "BedrockRuntime");
857
+ var BedrockRuntime = _BedrockRuntime;
858
+ (0, import_smithy_client.createAggregatedClient)(commands, BedrockRuntime);
859
+
860
+ // src/index.ts
861
+ var import_util_endpoints = require("@aws-sdk/util-endpoints");
862
+ // Annotate the CommonJS export names for ESM import in node:
863
+
864
+ 0 && (module.exports = {
865
+ AccessDeniedException,
866
+ BedrockRuntime,
867
+ BedrockRuntimeClient,
868
+ BedrockRuntimeServiceException,
869
+ InternalServerException,
870
+ InvokeModelCommand,
871
+ InvokeModelRequestFilterSensitiveLog,
872
+ InvokeModelResponseFilterSensitiveLog,
873
+ InvokeModelWithResponseStreamCommand,
874
+ InvokeModelWithResponseStreamRequestFilterSensitiveLog,
875
+ InvokeModelWithResponseStreamResponseFilterSensitiveLog,
876
+ ModelErrorException,
877
+ ModelNotReadyException,
878
+ ModelStreamErrorException,
879
+ ModelTimeoutException,
880
+ PayloadPartFilterSensitiveLog,
881
+ ResourceNotFoundException,
882
+ ResponseStream,
883
+ ResponseStreamFilterSensitiveLog,
884
+ ServiceQuotaExceededException,
885
+ ThrottlingException,
886
+ ValidationException,
887
+ __Client
888
+ });
889
+