@aws-sdk/client-bedrock-runtime 3.927.0 → 3.929.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.
Files changed (34) hide show
  1. package/dist-cjs/index.js +1760 -2169
  2. package/dist-cjs/runtimeConfig.shared.js +2 -0
  3. package/dist-es/BedrockRuntimeClient.js +2 -0
  4. package/dist-es/commands/ApplyGuardrailCommand.js +3 -10
  5. package/dist-es/commands/ConverseCommand.js +3 -10
  6. package/dist-es/commands/ConverseStreamCommand.js +3 -10
  7. package/dist-es/commands/CountTokensCommand.js +3 -10
  8. package/dist-es/commands/GetAsyncInvokeCommand.js +3 -10
  9. package/dist-es/commands/InvokeModelCommand.js +3 -10
  10. package/dist-es/commands/InvokeModelWithBidirectionalStreamCommand.js +2 -7
  11. package/dist-es/commands/InvokeModelWithResponseStreamCommand.js +3 -10
  12. package/dist-es/commands/ListAsyncInvokesCommand.js +3 -10
  13. package/dist-es/commands/StartAsyncInvokeCommand.js +3 -10
  14. package/dist-es/models/models_0.js +0 -430
  15. package/dist-es/runtimeConfig.shared.js +2 -0
  16. package/dist-es/schemas/schemas_0.js +1720 -0
  17. package/dist-types/BedrockRuntimeClient.d.ts +10 -1
  18. package/dist-types/models/models_0.d.ts +0 -240
  19. package/dist-types/runtimeConfig.browser.d.ts +1 -0
  20. package/dist-types/runtimeConfig.d.ts +1 -0
  21. package/dist-types/runtimeConfig.native.d.ts +1 -0
  22. package/dist-types/runtimeConfig.shared.d.ts +1 -0
  23. package/dist-types/schemas/schemas_0.d.ts +211 -0
  24. package/dist-types/ts3.4/BedrockRuntimeClient.d.ts +4 -0
  25. package/dist-types/ts3.4/models/models_0.d.ts +0 -174
  26. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +4 -0
  27. package/dist-types/ts3.4/runtimeConfig.d.ts +4 -0
  28. package/dist-types/ts3.4/runtimeConfig.native.d.ts +4 -0
  29. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +4 -0
  30. package/dist-types/ts3.4/schemas/schemas_0.d.ts +218 -0
  31. package/package.json +6 -7
  32. package/dist-es/protocols/Aws_restJson1.js +0 -1589
  33. package/dist-types/protocols/Aws_restJson1.d.ts +0 -92
  34. package/dist-types/ts3.4/protocols/Aws_restJson1.d.ts +0 -128
@@ -1,1589 +0,0 @@
1
- import { awsExpectUnion as __expectUnion, loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody, } from "@aws-sdk/core";
2
- import { requestBuilder as rb } from "@smithy/core";
3
- import { _json, collectBody, decorateServiceException as __decorateServiceException, expectBoolean as __expectBoolean, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, isSerializableHeaderValue, limitedParseDouble as __limitedParseDouble, map, parseRfc3339DateTimeWithOffset as __parseRfc3339DateTimeWithOffset, serializeDateTime as __serializeDateTime, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
4
- import { v4 as generateIdempotencyToken } from "@smithy/uuid";
5
- import { BedrockRuntimeServiceException as __BaseException } from "../models/BedrockRuntimeServiceException";
6
- import { AccessDeniedException, ConflictException, ContentBlock, CountTokensInput, DocumentSource, GuardrailContentBlock, GuardrailConverseContentBlock, GuardrailConverseImageSource, GuardrailImageSource, ImageSource, InternalServerException, InvokeModelWithBidirectionalStreamInput, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ReasoningContentBlock, ResourceNotFoundException, ServiceQuotaExceededException, ServiceUnavailableException, SystemContentBlock, ThrottlingException, Tool, ToolInputSchema, ToolResultContentBlock, ValidationException, VideoSource, } from "../models/models_0";
7
- export const se_ApplyGuardrailCommand = async (input, context) => {
8
- const b = rb(input, context);
9
- const headers = {
10
- "content-type": "application/json",
11
- };
12
- b.bp("/guardrail/{guardrailIdentifier}/version/{guardrailVersion}/apply");
13
- b.p("guardrailIdentifier", () => input.guardrailIdentifier, "{guardrailIdentifier}", false);
14
- b.p("guardrailVersion", () => input.guardrailVersion, "{guardrailVersion}", false);
15
- let body;
16
- body = JSON.stringify(take(input, {
17
- content: (_) => se_GuardrailContentBlockList(_, context),
18
- outputScope: [],
19
- source: [],
20
- }));
21
- b.m("POST").h(headers).b(body);
22
- return b.build();
23
- };
24
- export const se_ConverseCommand = async (input, context) => {
25
- const b = rb(input, context);
26
- const headers = {
27
- "content-type": "application/json",
28
- };
29
- b.bp("/model/{modelId}/converse");
30
- b.p("modelId", () => input.modelId, "{modelId}", false);
31
- let body;
32
- body = JSON.stringify(take(input, {
33
- additionalModelRequestFields: (_) => se_Document(_, context),
34
- additionalModelResponseFieldPaths: (_) => _json(_),
35
- guardrailConfig: (_) => _json(_),
36
- inferenceConfig: (_) => se_InferenceConfiguration(_, context),
37
- messages: (_) => se_Messages(_, context),
38
- performanceConfig: (_) => _json(_),
39
- promptVariables: (_) => _json(_),
40
- requestMetadata: (_) => _json(_),
41
- system: (_) => se_SystemContentBlocks(_, context),
42
- toolConfig: (_) => se_ToolConfiguration(_, context),
43
- }));
44
- b.m("POST").h(headers).b(body);
45
- return b.build();
46
- };
47
- export const se_ConverseStreamCommand = async (input, context) => {
48
- const b = rb(input, context);
49
- const headers = {
50
- "content-type": "application/json",
51
- };
52
- b.bp("/model/{modelId}/converse-stream");
53
- b.p("modelId", () => input.modelId, "{modelId}", false);
54
- let body;
55
- body = JSON.stringify(take(input, {
56
- additionalModelRequestFields: (_) => se_Document(_, context),
57
- additionalModelResponseFieldPaths: (_) => _json(_),
58
- guardrailConfig: (_) => _json(_),
59
- inferenceConfig: (_) => se_InferenceConfiguration(_, context),
60
- messages: (_) => se_Messages(_, context),
61
- performanceConfig: (_) => _json(_),
62
- promptVariables: (_) => _json(_),
63
- requestMetadata: (_) => _json(_),
64
- system: (_) => se_SystemContentBlocks(_, context),
65
- toolConfig: (_) => se_ToolConfiguration(_, context),
66
- }));
67
- b.m("POST").h(headers).b(body);
68
- return b.build();
69
- };
70
- export const se_CountTokensCommand = async (input, context) => {
71
- const b = rb(input, context);
72
- const headers = {
73
- "content-type": "application/json",
74
- };
75
- b.bp("/model/{modelId}/count-tokens");
76
- b.p("modelId", () => input.modelId, "{modelId}", false);
77
- let body;
78
- body = JSON.stringify(take(input, {
79
- input: (_) => se_CountTokensInput(_, context),
80
- }));
81
- b.m("POST").h(headers).b(body);
82
- return b.build();
83
- };
84
- export const se_GetAsyncInvokeCommand = async (input, context) => {
85
- const b = rb(input, context);
86
- const headers = {};
87
- b.bp("/async-invoke/{invocationArn}");
88
- b.p("invocationArn", () => input.invocationArn, "{invocationArn}", false);
89
- let body;
90
- b.m("GET").h(headers).b(body);
91
- return b.build();
92
- };
93
- export const se_InvokeModelCommand = async (input, context) => {
94
- const b = rb(input, context);
95
- const headers = map({}, isSerializableHeaderValue, {
96
- [_ct]: input[_cT] || "application/octet-stream",
97
- [_a]: input[_a],
98
- [_xabt]: input[_t],
99
- [_xabg]: input[_gI],
100
- [_xabg_]: input[_gV],
101
- [_xabpl]: input[_pCL],
102
- });
103
- b.bp("/model/{modelId}/invoke");
104
- b.p("modelId", () => input.modelId, "{modelId}", false);
105
- let body;
106
- if (input.body !== undefined) {
107
- body = input.body;
108
- }
109
- b.m("POST").h(headers).b(body);
110
- return b.build();
111
- };
112
- export const se_InvokeModelWithBidirectionalStreamCommand = async (input, context) => {
113
- const b = rb(input, context);
114
- const headers = {
115
- "content-type": "application/json",
116
- };
117
- b.bp("/model/{modelId}/invoke-with-bidirectional-stream");
118
- b.p("modelId", () => input.modelId, "{modelId}", false);
119
- let body;
120
- if (input.body !== undefined) {
121
- body = se_InvokeModelWithBidirectionalStreamInput(input.body, context);
122
- }
123
- b.m("POST").h(headers).b(body);
124
- return b.build();
125
- };
126
- export const se_InvokeModelWithResponseStreamCommand = async (input, context) => {
127
- const b = rb(input, context);
128
- const headers = map({}, isSerializableHeaderValue, {
129
- [_ct]: input[_cT] || "application/octet-stream",
130
- [_xaba]: input[_a],
131
- [_xabt]: input[_t],
132
- [_xabg]: input[_gI],
133
- [_xabg_]: input[_gV],
134
- [_xabpl]: input[_pCL],
135
- });
136
- b.bp("/model/{modelId}/invoke-with-response-stream");
137
- b.p("modelId", () => input.modelId, "{modelId}", false);
138
- let body;
139
- if (input.body !== undefined) {
140
- body = input.body;
141
- }
142
- b.m("POST").h(headers).b(body);
143
- return b.build();
144
- };
145
- export const se_ListAsyncInvokesCommand = async (input, context) => {
146
- const b = rb(input, context);
147
- const headers = {};
148
- b.bp("/async-invoke");
149
- const query = map({
150
- [_sTA]: [() => input.submitTimeAfter !== void 0, () => __serializeDateTime(input[_sTA]).toString()],
151
- [_sTB]: [() => input.submitTimeBefore !== void 0, () => __serializeDateTime(input[_sTB]).toString()],
152
- [_sE]: [, input[_sE]],
153
- [_mR]: [() => input.maxResults !== void 0, () => input[_mR].toString()],
154
- [_nT]: [, input[_nT]],
155
- [_sB]: [, input[_sB]],
156
- [_sO]: [, input[_sO]],
157
- });
158
- let body;
159
- b.m("GET").h(headers).q(query).b(body);
160
- return b.build();
161
- };
162
- export const se_StartAsyncInvokeCommand = async (input, context) => {
163
- const b = rb(input, context);
164
- const headers = {
165
- "content-type": "application/json",
166
- };
167
- b.bp("/async-invoke");
168
- let body;
169
- body = JSON.stringify(take(input, {
170
- clientRequestToken: [true, (_) => _ ?? generateIdempotencyToken()],
171
- modelId: [],
172
- modelInput: (_) => se_ModelInputPayload(_, context),
173
- outputDataConfig: (_) => _json(_),
174
- tags: (_) => _json(_),
175
- }));
176
- b.m("POST").h(headers).b(body);
177
- return b.build();
178
- };
179
- export const de_ApplyGuardrailCommand = async (output, context) => {
180
- if (output.statusCode !== 200 && output.statusCode >= 300) {
181
- return de_CommandError(output, context);
182
- }
183
- const contents = map({
184
- $metadata: deserializeMetadata(output),
185
- });
186
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
187
- const doc = take(data, {
188
- action: __expectString,
189
- actionReason: __expectString,
190
- assessments: (_) => de_GuardrailAssessmentList(_, context),
191
- guardrailCoverage: _json,
192
- outputs: _json,
193
- usage: _json,
194
- });
195
- Object.assign(contents, doc);
196
- return contents;
197
- };
198
- export const de_ConverseCommand = async (output, context) => {
199
- if (output.statusCode !== 200 && output.statusCode >= 300) {
200
- return de_CommandError(output, context);
201
- }
202
- const contents = map({
203
- $metadata: deserializeMetadata(output),
204
- });
205
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
206
- const doc = take(data, {
207
- additionalModelResponseFields: (_) => de_Document(_, context),
208
- metrics: _json,
209
- output: (_) => de_ConverseOutput(__expectUnion(_), context),
210
- performanceConfig: _json,
211
- stopReason: __expectString,
212
- trace: (_) => de_ConverseTrace(_, context),
213
- usage: _json,
214
- });
215
- Object.assign(contents, doc);
216
- return contents;
217
- };
218
- export const de_ConverseStreamCommand = async (output, context) => {
219
- if (output.statusCode !== 200 && output.statusCode >= 300) {
220
- return de_CommandError(output, context);
221
- }
222
- const contents = map({
223
- $metadata: deserializeMetadata(output),
224
- });
225
- const data = output.body;
226
- contents.stream = de_ConverseStreamOutput(data, context);
227
- return contents;
228
- };
229
- export const de_CountTokensCommand = async (output, context) => {
230
- if (output.statusCode !== 200 && output.statusCode >= 300) {
231
- return de_CommandError(output, context);
232
- }
233
- const contents = map({
234
- $metadata: deserializeMetadata(output),
235
- });
236
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
237
- const doc = take(data, {
238
- inputTokens: __expectInt32,
239
- });
240
- Object.assign(contents, doc);
241
- return contents;
242
- };
243
- export const de_GetAsyncInvokeCommand = async (output, context) => {
244
- if (output.statusCode !== 200 && output.statusCode >= 300) {
245
- return de_CommandError(output, context);
246
- }
247
- const contents = map({
248
- $metadata: deserializeMetadata(output),
249
- });
250
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
251
- const doc = take(data, {
252
- clientRequestToken: __expectString,
253
- endTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
254
- failureMessage: __expectString,
255
- invocationArn: __expectString,
256
- lastModifiedTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
257
- modelArn: __expectString,
258
- outputDataConfig: (_) => _json(__expectUnion(_)),
259
- status: __expectString,
260
- submitTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
261
- });
262
- Object.assign(contents, doc);
263
- return contents;
264
- };
265
- export const de_InvokeModelCommand = async (output, context) => {
266
- if (output.statusCode !== 200 && output.statusCode >= 300) {
267
- return de_CommandError(output, context);
268
- }
269
- const contents = map({
270
- $metadata: deserializeMetadata(output),
271
- [_cT]: [, output.headers[_ct]],
272
- [_pCL]: [, output.headers[_xabpl]],
273
- });
274
- const data = await collectBody(output.body, context);
275
- contents.body = data;
276
- return contents;
277
- };
278
- export const de_InvokeModelWithBidirectionalStreamCommand = async (output, context) => {
279
- if (output.statusCode !== 200 && output.statusCode >= 300) {
280
- return de_CommandError(output, context);
281
- }
282
- const contents = map({
283
- $metadata: deserializeMetadata(output),
284
- });
285
- const data = output.body;
286
- contents.body = de_InvokeModelWithBidirectionalStreamOutput(data, context);
287
- return contents;
288
- };
289
- export const de_InvokeModelWithResponseStreamCommand = async (output, context) => {
290
- if (output.statusCode !== 200 && output.statusCode >= 300) {
291
- return de_CommandError(output, context);
292
- }
293
- const contents = map({
294
- $metadata: deserializeMetadata(output),
295
- [_cT]: [, output.headers[_xabct]],
296
- [_pCL]: [, output.headers[_xabpl]],
297
- });
298
- const data = output.body;
299
- contents.body = de_ResponseStream(data, context);
300
- return contents;
301
- };
302
- export const de_ListAsyncInvokesCommand = async (output, context) => {
303
- if (output.statusCode !== 200 && output.statusCode >= 300) {
304
- return de_CommandError(output, context);
305
- }
306
- const contents = map({
307
- $metadata: deserializeMetadata(output),
308
- });
309
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
310
- const doc = take(data, {
311
- asyncInvokeSummaries: (_) => de_AsyncInvokeSummaries(_, context),
312
- nextToken: __expectString,
313
- });
314
- Object.assign(contents, doc);
315
- return contents;
316
- };
317
- export const de_StartAsyncInvokeCommand = async (output, context) => {
318
- if (output.statusCode !== 200 && output.statusCode >= 300) {
319
- return de_CommandError(output, context);
320
- }
321
- const contents = map({
322
- $metadata: deserializeMetadata(output),
323
- });
324
- const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
325
- const doc = take(data, {
326
- invocationArn: __expectString,
327
- });
328
- Object.assign(contents, doc);
329
- return contents;
330
- };
331
- const de_CommandError = async (output, context) => {
332
- const parsedOutput = {
333
- ...output,
334
- body: await parseErrorBody(output.body, context),
335
- };
336
- const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
337
- switch (errorCode) {
338
- case "AccessDeniedException":
339
- case "com.amazonaws.bedrockruntime#AccessDeniedException":
340
- throw await de_AccessDeniedExceptionRes(parsedOutput, context);
341
- case "InternalServerException":
342
- case "com.amazonaws.bedrockruntime#InternalServerException":
343
- throw await de_InternalServerExceptionRes(parsedOutput, context);
344
- case "ResourceNotFoundException":
345
- case "com.amazonaws.bedrockruntime#ResourceNotFoundException":
346
- throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
347
- case "ServiceQuotaExceededException":
348
- case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
349
- throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
350
- case "ServiceUnavailableException":
351
- case "com.amazonaws.bedrockruntime#ServiceUnavailableException":
352
- throw await de_ServiceUnavailableExceptionRes(parsedOutput, context);
353
- case "ThrottlingException":
354
- case "com.amazonaws.bedrockruntime#ThrottlingException":
355
- throw await de_ThrottlingExceptionRes(parsedOutput, context);
356
- case "ValidationException":
357
- case "com.amazonaws.bedrockruntime#ValidationException":
358
- throw await de_ValidationExceptionRes(parsedOutput, context);
359
- case "ModelErrorException":
360
- case "com.amazonaws.bedrockruntime#ModelErrorException":
361
- throw await de_ModelErrorExceptionRes(parsedOutput, context);
362
- case "ModelNotReadyException":
363
- case "com.amazonaws.bedrockruntime#ModelNotReadyException":
364
- throw await de_ModelNotReadyExceptionRes(parsedOutput, context);
365
- case "ModelTimeoutException":
366
- case "com.amazonaws.bedrockruntime#ModelTimeoutException":
367
- throw await de_ModelTimeoutExceptionRes(parsedOutput, context);
368
- case "ModelStreamErrorException":
369
- case "com.amazonaws.bedrockruntime#ModelStreamErrorException":
370
- throw await de_ModelStreamErrorExceptionRes(parsedOutput, context);
371
- case "ConflictException":
372
- case "com.amazonaws.bedrockruntime#ConflictException":
373
- throw await de_ConflictExceptionRes(parsedOutput, context);
374
- default:
375
- const parsedBody = parsedOutput.body;
376
- return throwDefaultError({
377
- output,
378
- parsedBody,
379
- errorCode,
380
- });
381
- }
382
- };
383
- const throwDefaultError = withBaseException(__BaseException);
384
- const de_AccessDeniedExceptionRes = async (parsedOutput, context) => {
385
- const contents = map({});
386
- const data = parsedOutput.body;
387
- const doc = take(data, {
388
- message: __expectString,
389
- });
390
- Object.assign(contents, doc);
391
- const exception = new AccessDeniedException({
392
- $metadata: deserializeMetadata(parsedOutput),
393
- ...contents,
394
- });
395
- return __decorateServiceException(exception, parsedOutput.body);
396
- };
397
- const de_ConflictExceptionRes = async (parsedOutput, context) => {
398
- const contents = map({});
399
- const data = parsedOutput.body;
400
- const doc = take(data, {
401
- message: __expectString,
402
- });
403
- Object.assign(contents, doc);
404
- const exception = new ConflictException({
405
- $metadata: deserializeMetadata(parsedOutput),
406
- ...contents,
407
- });
408
- return __decorateServiceException(exception, parsedOutput.body);
409
- };
410
- const de_InternalServerExceptionRes = async (parsedOutput, context) => {
411
- const contents = map({});
412
- const data = parsedOutput.body;
413
- const doc = take(data, {
414
- message: __expectString,
415
- });
416
- Object.assign(contents, doc);
417
- const exception = new InternalServerException({
418
- $metadata: deserializeMetadata(parsedOutput),
419
- ...contents,
420
- });
421
- return __decorateServiceException(exception, parsedOutput.body);
422
- };
423
- const de_ModelErrorExceptionRes = async (parsedOutput, context) => {
424
- const contents = map({});
425
- const data = parsedOutput.body;
426
- const doc = take(data, {
427
- message: __expectString,
428
- originalStatusCode: __expectInt32,
429
- resourceName: __expectString,
430
- });
431
- Object.assign(contents, doc);
432
- const exception = new ModelErrorException({
433
- $metadata: deserializeMetadata(parsedOutput),
434
- ...contents,
435
- });
436
- return __decorateServiceException(exception, parsedOutput.body);
437
- };
438
- const de_ModelNotReadyExceptionRes = async (parsedOutput, context) => {
439
- const contents = map({});
440
- const data = parsedOutput.body;
441
- const doc = take(data, {
442
- message: __expectString,
443
- });
444
- Object.assign(contents, doc);
445
- const exception = new ModelNotReadyException({
446
- $metadata: deserializeMetadata(parsedOutput),
447
- ...contents,
448
- });
449
- return __decorateServiceException(exception, parsedOutput.body);
450
- };
451
- const de_ModelStreamErrorExceptionRes = async (parsedOutput, context) => {
452
- const contents = map({});
453
- const data = parsedOutput.body;
454
- const doc = take(data, {
455
- message: __expectString,
456
- originalMessage: __expectString,
457
- originalStatusCode: __expectInt32,
458
- });
459
- Object.assign(contents, doc);
460
- const exception = new ModelStreamErrorException({
461
- $metadata: deserializeMetadata(parsedOutput),
462
- ...contents,
463
- });
464
- return __decorateServiceException(exception, parsedOutput.body);
465
- };
466
- const de_ModelTimeoutExceptionRes = async (parsedOutput, context) => {
467
- const contents = map({});
468
- const data = parsedOutput.body;
469
- const doc = take(data, {
470
- message: __expectString,
471
- });
472
- Object.assign(contents, doc);
473
- const exception = new ModelTimeoutException({
474
- $metadata: deserializeMetadata(parsedOutput),
475
- ...contents,
476
- });
477
- return __decorateServiceException(exception, parsedOutput.body);
478
- };
479
- const de_ResourceNotFoundExceptionRes = async (parsedOutput, context) => {
480
- const contents = map({});
481
- const data = parsedOutput.body;
482
- const doc = take(data, {
483
- message: __expectString,
484
- });
485
- Object.assign(contents, doc);
486
- const exception = new ResourceNotFoundException({
487
- $metadata: deserializeMetadata(parsedOutput),
488
- ...contents,
489
- });
490
- return __decorateServiceException(exception, parsedOutput.body);
491
- };
492
- const de_ServiceQuotaExceededExceptionRes = async (parsedOutput, context) => {
493
- const contents = map({});
494
- const data = parsedOutput.body;
495
- const doc = take(data, {
496
- message: __expectString,
497
- });
498
- Object.assign(contents, doc);
499
- const exception = new ServiceQuotaExceededException({
500
- $metadata: deserializeMetadata(parsedOutput),
501
- ...contents,
502
- });
503
- return __decorateServiceException(exception, parsedOutput.body);
504
- };
505
- const de_ServiceUnavailableExceptionRes = async (parsedOutput, context) => {
506
- const contents = map({});
507
- const data = parsedOutput.body;
508
- const doc = take(data, {
509
- message: __expectString,
510
- });
511
- Object.assign(contents, doc);
512
- const exception = new ServiceUnavailableException({
513
- $metadata: deserializeMetadata(parsedOutput),
514
- ...contents,
515
- });
516
- return __decorateServiceException(exception, parsedOutput.body);
517
- };
518
- const de_ThrottlingExceptionRes = async (parsedOutput, context) => {
519
- const contents = map({});
520
- const data = parsedOutput.body;
521
- const doc = take(data, {
522
- message: __expectString,
523
- });
524
- Object.assign(contents, doc);
525
- const exception = new ThrottlingException({
526
- $metadata: deserializeMetadata(parsedOutput),
527
- ...contents,
528
- });
529
- return __decorateServiceException(exception, parsedOutput.body);
530
- };
531
- const de_ValidationExceptionRes = async (parsedOutput, context) => {
532
- const contents = map({});
533
- const data = parsedOutput.body;
534
- const doc = take(data, {
535
- message: __expectString,
536
- });
537
- Object.assign(contents, doc);
538
- const exception = new ValidationException({
539
- $metadata: deserializeMetadata(parsedOutput),
540
- ...contents,
541
- });
542
- return __decorateServiceException(exception, parsedOutput.body);
543
- };
544
- const se_InvokeModelWithBidirectionalStreamInput = (input, context) => {
545
- const eventMarshallingVisitor = (event) => InvokeModelWithBidirectionalStreamInput.visit(event, {
546
- chunk: (value) => se_BidirectionalInputPayloadPart_event(value, context),
547
- _: (value) => value,
548
- });
549
- return context.eventStreamMarshaller.serialize(input, eventMarshallingVisitor);
550
- };
551
- const se_BidirectionalInputPayloadPart_event = (input, context) => {
552
- const headers = {
553
- ":event-type": { type: "string", value: "chunk" },
554
- ":message-type": { type: "string", value: "event" },
555
- ":content-type": { type: "string", value: "application/json" },
556
- };
557
- let body = new Uint8Array();
558
- body = se_BidirectionalInputPayloadPart(input, context);
559
- body = context.utf8Decoder(JSON.stringify(body));
560
- return { headers, body };
561
- };
562
- const de_ConverseStreamOutput = (output, context) => {
563
- return context.eventStreamMarshaller.deserialize(output, async (event) => {
564
- if (event["messageStart"] != null) {
565
- return {
566
- messageStart: await de_MessageStartEvent_event(event["messageStart"], context),
567
- };
568
- }
569
- if (event["contentBlockStart"] != null) {
570
- return {
571
- contentBlockStart: await de_ContentBlockStartEvent_event(event["contentBlockStart"], context),
572
- };
573
- }
574
- if (event["contentBlockDelta"] != null) {
575
- return {
576
- contentBlockDelta: await de_ContentBlockDeltaEvent_event(event["contentBlockDelta"], context),
577
- };
578
- }
579
- if (event["contentBlockStop"] != null) {
580
- return {
581
- contentBlockStop: await de_ContentBlockStopEvent_event(event["contentBlockStop"], context),
582
- };
583
- }
584
- if (event["messageStop"] != null) {
585
- return {
586
- messageStop: await de_MessageStopEvent_event(event["messageStop"], context),
587
- };
588
- }
589
- if (event["metadata"] != null) {
590
- return {
591
- metadata: await de_ConverseStreamMetadataEvent_event(event["metadata"], context),
592
- };
593
- }
594
- if (event["internalServerException"] != null) {
595
- return {
596
- internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
597
- };
598
- }
599
- if (event["modelStreamErrorException"] != null) {
600
- return {
601
- modelStreamErrorException: await de_ModelStreamErrorException_event(event["modelStreamErrorException"], context),
602
- };
603
- }
604
- if (event["validationException"] != null) {
605
- return {
606
- validationException: await de_ValidationException_event(event["validationException"], context),
607
- };
608
- }
609
- if (event["throttlingException"] != null) {
610
- return {
611
- throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
612
- };
613
- }
614
- if (event["serviceUnavailableException"] != null) {
615
- return {
616
- serviceUnavailableException: await de_ServiceUnavailableException_event(event["serviceUnavailableException"], context),
617
- };
618
- }
619
- return { $unknown: event };
620
- });
621
- };
622
- const de_InvokeModelWithBidirectionalStreamOutput = (output, context) => {
623
- return context.eventStreamMarshaller.deserialize(output, async (event) => {
624
- if (event["chunk"] != null) {
625
- return {
626
- chunk: await de_BidirectionalOutputPayloadPart_event(event["chunk"], context),
627
- };
628
- }
629
- if (event["internalServerException"] != null) {
630
- return {
631
- internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
632
- };
633
- }
634
- if (event["modelStreamErrorException"] != null) {
635
- return {
636
- modelStreamErrorException: await de_ModelStreamErrorException_event(event["modelStreamErrorException"], context),
637
- };
638
- }
639
- if (event["validationException"] != null) {
640
- return {
641
- validationException: await de_ValidationException_event(event["validationException"], context),
642
- };
643
- }
644
- if (event["throttlingException"] != null) {
645
- return {
646
- throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
647
- };
648
- }
649
- if (event["modelTimeoutException"] != null) {
650
- return {
651
- modelTimeoutException: await de_ModelTimeoutException_event(event["modelTimeoutException"], context),
652
- };
653
- }
654
- if (event["serviceUnavailableException"] != null) {
655
- return {
656
- serviceUnavailableException: await de_ServiceUnavailableException_event(event["serviceUnavailableException"], context),
657
- };
658
- }
659
- return { $unknown: event };
660
- });
661
- };
662
- const de_ResponseStream = (output, context) => {
663
- return context.eventStreamMarshaller.deserialize(output, async (event) => {
664
- if (event["chunk"] != null) {
665
- return {
666
- chunk: await de_PayloadPart_event(event["chunk"], context),
667
- };
668
- }
669
- if (event["internalServerException"] != null) {
670
- return {
671
- internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
672
- };
673
- }
674
- if (event["modelStreamErrorException"] != null) {
675
- return {
676
- modelStreamErrorException: await de_ModelStreamErrorException_event(event["modelStreamErrorException"], context),
677
- };
678
- }
679
- if (event["validationException"] != null) {
680
- return {
681
- validationException: await de_ValidationException_event(event["validationException"], context),
682
- };
683
- }
684
- if (event["throttlingException"] != null) {
685
- return {
686
- throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
687
- };
688
- }
689
- if (event["modelTimeoutException"] != null) {
690
- return {
691
- modelTimeoutException: await de_ModelTimeoutException_event(event["modelTimeoutException"], context),
692
- };
693
- }
694
- if (event["serviceUnavailableException"] != null) {
695
- return {
696
- serviceUnavailableException: await de_ServiceUnavailableException_event(event["serviceUnavailableException"], context),
697
- };
698
- }
699
- return { $unknown: event };
700
- });
701
- };
702
- const de_BidirectionalOutputPayloadPart_event = async (output, context) => {
703
- const contents = {};
704
- const data = await parseBody(output.body, context);
705
- Object.assign(contents, de_BidirectionalOutputPayloadPart(data, context));
706
- return contents;
707
- };
708
- const de_ContentBlockDeltaEvent_event = async (output, context) => {
709
- const contents = {};
710
- const data = await parseBody(output.body, context);
711
- Object.assign(contents, de_ContentBlockDeltaEvent(data, context));
712
- return contents;
713
- };
714
- const de_ContentBlockStartEvent_event = async (output, context) => {
715
- const contents = {};
716
- const data = await parseBody(output.body, context);
717
- Object.assign(contents, _json(data));
718
- return contents;
719
- };
720
- const de_ContentBlockStopEvent_event = async (output, context) => {
721
- const contents = {};
722
- const data = await parseBody(output.body, context);
723
- Object.assign(contents, _json(data));
724
- return contents;
725
- };
726
- const de_ConverseStreamMetadataEvent_event = async (output, context) => {
727
- const contents = {};
728
- const data = await parseBody(output.body, context);
729
- Object.assign(contents, de_ConverseStreamMetadataEvent(data, context));
730
- return contents;
731
- };
732
- const de_InternalServerException_event = async (output, context) => {
733
- const parsedOutput = {
734
- ...output,
735
- body: await parseBody(output.body, context),
736
- };
737
- return de_InternalServerExceptionRes(parsedOutput, context);
738
- };
739
- const de_MessageStartEvent_event = async (output, context) => {
740
- const contents = {};
741
- const data = await parseBody(output.body, context);
742
- Object.assign(contents, _json(data));
743
- return contents;
744
- };
745
- const de_MessageStopEvent_event = async (output, context) => {
746
- const contents = {};
747
- const data = await parseBody(output.body, context);
748
- Object.assign(contents, de_MessageStopEvent(data, context));
749
- return contents;
750
- };
751
- const de_ModelStreamErrorException_event = async (output, context) => {
752
- const parsedOutput = {
753
- ...output,
754
- body: await parseBody(output.body, context),
755
- };
756
- return de_ModelStreamErrorExceptionRes(parsedOutput, context);
757
- };
758
- const de_ModelTimeoutException_event = async (output, context) => {
759
- const parsedOutput = {
760
- ...output,
761
- body: await parseBody(output.body, context),
762
- };
763
- return de_ModelTimeoutExceptionRes(parsedOutput, context);
764
- };
765
- const de_PayloadPart_event = async (output, context) => {
766
- const contents = {};
767
- const data = await parseBody(output.body, context);
768
- Object.assign(contents, de_PayloadPart(data, context));
769
- return contents;
770
- };
771
- const de_ServiceUnavailableException_event = async (output, context) => {
772
- const parsedOutput = {
773
- ...output,
774
- body: await parseBody(output.body, context),
775
- };
776
- return de_ServiceUnavailableExceptionRes(parsedOutput, context);
777
- };
778
- const de_ThrottlingException_event = async (output, context) => {
779
- const parsedOutput = {
780
- ...output,
781
- body: await parseBody(output.body, context),
782
- };
783
- return de_ThrottlingExceptionRes(parsedOutput, context);
784
- };
785
- const de_ValidationException_event = async (output, context) => {
786
- const parsedOutput = {
787
- ...output,
788
- body: await parseBody(output.body, context),
789
- };
790
- return de_ValidationExceptionRes(parsedOutput, context);
791
- };
792
- const se_BidirectionalInputPayloadPart = (input, context) => {
793
- return take(input, {
794
- bytes: context.base64Encoder,
795
- });
796
- };
797
- const se_ContentBlock = (input, context) => {
798
- return ContentBlock.visit(input, {
799
- cachePoint: (value) => ({ cachePoint: _json(value) }),
800
- citationsContent: (value) => ({ citationsContent: _json(value) }),
801
- document: (value) => ({ document: se_DocumentBlock(value, context) }),
802
- guardContent: (value) => ({ guardContent: se_GuardrailConverseContentBlock(value, context) }),
803
- image: (value) => ({ image: se_ImageBlock(value, context) }),
804
- reasoningContent: (value) => ({ reasoningContent: se_ReasoningContentBlock(value, context) }),
805
- text: (value) => ({ text: value }),
806
- toolResult: (value) => ({ toolResult: se_ToolResultBlock(value, context) }),
807
- toolUse: (value) => ({ toolUse: se_ToolUseBlock(value, context) }),
808
- video: (value) => ({ video: se_VideoBlock(value, context) }),
809
- _: (name, value) => ({ [name]: value }),
810
- });
811
- };
812
- const se_ContentBlocks = (input, context) => {
813
- return input
814
- .filter((e) => e != null)
815
- .map((entry) => {
816
- return se_ContentBlock(entry, context);
817
- });
818
- };
819
- const se_ConverseTokensRequest = (input, context) => {
820
- return take(input, {
821
- messages: (_) => se_Messages(_, context),
822
- system: (_) => se_SystemContentBlocks(_, context),
823
- });
824
- };
825
- const se_CountTokensInput = (input, context) => {
826
- return CountTokensInput.visit(input, {
827
- converse: (value) => ({ converse: se_ConverseTokensRequest(value, context) }),
828
- invokeModel: (value) => ({ invokeModel: se_InvokeModelTokensRequest(value, context) }),
829
- _: (name, value) => ({ [name]: value }),
830
- });
831
- };
832
- const se_DocumentBlock = (input, context) => {
833
- return take(input, {
834
- citations: _json,
835
- context: [],
836
- format: [],
837
- name: [],
838
- source: (_) => se_DocumentSource(_, context),
839
- });
840
- };
841
- const se_DocumentSource = (input, context) => {
842
- return DocumentSource.visit(input, {
843
- bytes: (value) => ({ bytes: context.base64Encoder(value) }),
844
- content: (value) => ({ content: _json(value) }),
845
- s3Location: (value) => ({ s3Location: _json(value) }),
846
- text: (value) => ({ text: value }),
847
- _: (name, value) => ({ [name]: value }),
848
- });
849
- };
850
- const se_GuardrailContentBlock = (input, context) => {
851
- return GuardrailContentBlock.visit(input, {
852
- image: (value) => ({ image: se_GuardrailImageBlock(value, context) }),
853
- text: (value) => ({ text: _json(value) }),
854
- _: (name, value) => ({ [name]: value }),
855
- });
856
- };
857
- const se_GuardrailContentBlockList = (input, context) => {
858
- return input
859
- .filter((e) => e != null)
860
- .map((entry) => {
861
- return se_GuardrailContentBlock(entry, context);
862
- });
863
- };
864
- const se_GuardrailConverseContentBlock = (input, context) => {
865
- return GuardrailConverseContentBlock.visit(input, {
866
- image: (value) => ({ image: se_GuardrailConverseImageBlock(value, context) }),
867
- text: (value) => ({ text: _json(value) }),
868
- _: (name, value) => ({ [name]: value }),
869
- });
870
- };
871
- const se_GuardrailConverseImageBlock = (input, context) => {
872
- return take(input, {
873
- format: [],
874
- source: (_) => se_GuardrailConverseImageSource(_, context),
875
- });
876
- };
877
- const se_GuardrailConverseImageSource = (input, context) => {
878
- return GuardrailConverseImageSource.visit(input, {
879
- bytes: (value) => ({ bytes: context.base64Encoder(value) }),
880
- _: (name, value) => ({ [name]: value }),
881
- });
882
- };
883
- const se_GuardrailImageBlock = (input, context) => {
884
- return take(input, {
885
- format: [],
886
- source: (_) => se_GuardrailImageSource(_, context),
887
- });
888
- };
889
- const se_GuardrailImageSource = (input, context) => {
890
- return GuardrailImageSource.visit(input, {
891
- bytes: (value) => ({ bytes: context.base64Encoder(value) }),
892
- _: (name, value) => ({ [name]: value }),
893
- });
894
- };
895
- const se_ImageBlock = (input, context) => {
896
- return take(input, {
897
- format: [],
898
- source: (_) => se_ImageSource(_, context),
899
- });
900
- };
901
- const se_ImageSource = (input, context) => {
902
- return ImageSource.visit(input, {
903
- bytes: (value) => ({ bytes: context.base64Encoder(value) }),
904
- s3Location: (value) => ({ s3Location: _json(value) }),
905
- _: (name, value) => ({ [name]: value }),
906
- });
907
- };
908
- const se_InferenceConfiguration = (input, context) => {
909
- return take(input, {
910
- maxTokens: [],
911
- stopSequences: _json,
912
- temperature: __serializeFloat,
913
- topP: __serializeFloat,
914
- });
915
- };
916
- const se_InvokeModelTokensRequest = (input, context) => {
917
- return take(input, {
918
- body: context.base64Encoder,
919
- });
920
- };
921
- const se_Message = (input, context) => {
922
- return take(input, {
923
- content: (_) => se_ContentBlocks(_, context),
924
- role: [],
925
- });
926
- };
927
- const se_Messages = (input, context) => {
928
- return input
929
- .filter((e) => e != null)
930
- .map((entry) => {
931
- return se_Message(entry, context);
932
- });
933
- };
934
- const se_ModelInputPayload = (input, context) => {
935
- return input;
936
- };
937
- const se_ReasoningContentBlock = (input, context) => {
938
- return ReasoningContentBlock.visit(input, {
939
- reasoningText: (value) => ({ reasoningText: _json(value) }),
940
- redactedContent: (value) => ({ redactedContent: context.base64Encoder(value) }),
941
- _: (name, value) => ({ [name]: value }),
942
- });
943
- };
944
- const se_SystemContentBlock = (input, context) => {
945
- return SystemContentBlock.visit(input, {
946
- cachePoint: (value) => ({ cachePoint: _json(value) }),
947
- guardContent: (value) => ({ guardContent: se_GuardrailConverseContentBlock(value, context) }),
948
- text: (value) => ({ text: value }),
949
- _: (name, value) => ({ [name]: value }),
950
- });
951
- };
952
- const se_SystemContentBlocks = (input, context) => {
953
- return input
954
- .filter((e) => e != null)
955
- .map((entry) => {
956
- return se_SystemContentBlock(entry, context);
957
- });
958
- };
959
- const se_Tool = (input, context) => {
960
- return Tool.visit(input, {
961
- cachePoint: (value) => ({ cachePoint: _json(value) }),
962
- systemTool: (value) => ({ systemTool: _json(value) }),
963
- toolSpec: (value) => ({ toolSpec: se_ToolSpecification(value, context) }),
964
- _: (name, value) => ({ [name]: value }),
965
- });
966
- };
967
- const se_ToolConfiguration = (input, context) => {
968
- return take(input, {
969
- toolChoice: _json,
970
- tools: (_) => se_Tools(_, context),
971
- });
972
- };
973
- const se_ToolInputSchema = (input, context) => {
974
- return ToolInputSchema.visit(input, {
975
- json: (value) => ({ json: se_Document(value, context) }),
976
- _: (name, value) => ({ [name]: value }),
977
- });
978
- };
979
- const se_ToolResultBlock = (input, context) => {
980
- return take(input, {
981
- content: (_) => se_ToolResultContentBlocks(_, context),
982
- status: [],
983
- toolUseId: [],
984
- type: [],
985
- });
986
- };
987
- const se_ToolResultContentBlock = (input, context) => {
988
- return ToolResultContentBlock.visit(input, {
989
- document: (value) => ({ document: se_DocumentBlock(value, context) }),
990
- image: (value) => ({ image: se_ImageBlock(value, context) }),
991
- json: (value) => ({ json: se_Document(value, context) }),
992
- text: (value) => ({ text: value }),
993
- video: (value) => ({ video: se_VideoBlock(value, context) }),
994
- _: (name, value) => ({ [name]: value }),
995
- });
996
- };
997
- const se_ToolResultContentBlocks = (input, context) => {
998
- return input
999
- .filter((e) => e != null)
1000
- .map((entry) => {
1001
- return se_ToolResultContentBlock(entry, context);
1002
- });
1003
- };
1004
- const se_Tools = (input, context) => {
1005
- return input
1006
- .filter((e) => e != null)
1007
- .map((entry) => {
1008
- return se_Tool(entry, context);
1009
- });
1010
- };
1011
- const se_ToolSpecification = (input, context) => {
1012
- return take(input, {
1013
- description: [],
1014
- inputSchema: (_) => se_ToolInputSchema(_, context),
1015
- name: [],
1016
- });
1017
- };
1018
- const se_ToolUseBlock = (input, context) => {
1019
- return take(input, {
1020
- input: (_) => se_Document(_, context),
1021
- name: [],
1022
- toolUseId: [],
1023
- type: [],
1024
- });
1025
- };
1026
- const se_VideoBlock = (input, context) => {
1027
- return take(input, {
1028
- format: [],
1029
- source: (_) => se_VideoSource(_, context),
1030
- });
1031
- };
1032
- const se_VideoSource = (input, context) => {
1033
- return VideoSource.visit(input, {
1034
- bytes: (value) => ({ bytes: context.base64Encoder(value) }),
1035
- s3Location: (value) => ({ s3Location: _json(value) }),
1036
- _: (name, value) => ({ [name]: value }),
1037
- });
1038
- };
1039
- const se_Document = (input, context) => {
1040
- return input;
1041
- };
1042
- const de_AsyncInvokeSummaries = (output, context) => {
1043
- const retVal = (output || [])
1044
- .filter((e) => e != null)
1045
- .map((entry) => {
1046
- return de_AsyncInvokeSummary(entry, context);
1047
- });
1048
- return retVal;
1049
- };
1050
- const de_AsyncInvokeSummary = (output, context) => {
1051
- return take(output, {
1052
- clientRequestToken: __expectString,
1053
- endTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
1054
- failureMessage: __expectString,
1055
- invocationArn: __expectString,
1056
- lastModifiedTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
1057
- modelArn: __expectString,
1058
- outputDataConfig: (_) => _json(__expectUnion(_)),
1059
- status: __expectString,
1060
- submitTime: (_) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
1061
- });
1062
- };
1063
- const de_BidirectionalOutputPayloadPart = (output, context) => {
1064
- return take(output, {
1065
- bytes: context.base64Decoder,
1066
- });
1067
- };
1068
- const de_ContentBlock = (output, context) => {
1069
- if (output.cachePoint != null) {
1070
- return {
1071
- cachePoint: _json(output.cachePoint),
1072
- };
1073
- }
1074
- if (output.citationsContent != null) {
1075
- return {
1076
- citationsContent: _json(output.citationsContent),
1077
- };
1078
- }
1079
- if (output.document != null) {
1080
- return {
1081
- document: de_DocumentBlock(output.document, context),
1082
- };
1083
- }
1084
- if (output.guardContent != null) {
1085
- return {
1086
- guardContent: de_GuardrailConverseContentBlock(__expectUnion(output.guardContent), context),
1087
- };
1088
- }
1089
- if (output.image != null) {
1090
- return {
1091
- image: de_ImageBlock(output.image, context),
1092
- };
1093
- }
1094
- if (output.reasoningContent != null) {
1095
- return {
1096
- reasoningContent: de_ReasoningContentBlock(__expectUnion(output.reasoningContent), context),
1097
- };
1098
- }
1099
- if (__expectString(output.text) !== undefined) {
1100
- return { text: __expectString(output.text) };
1101
- }
1102
- if (output.toolResult != null) {
1103
- return {
1104
- toolResult: de_ToolResultBlock(output.toolResult, context),
1105
- };
1106
- }
1107
- if (output.toolUse != null) {
1108
- return {
1109
- toolUse: de_ToolUseBlock(output.toolUse, context),
1110
- };
1111
- }
1112
- if (output.video != null) {
1113
- return {
1114
- video: de_VideoBlock(output.video, context),
1115
- };
1116
- }
1117
- return { $unknown: Object.entries(output)[0] };
1118
- };
1119
- const de_ContentBlockDelta = (output, context) => {
1120
- if (output.citation != null) {
1121
- return {
1122
- citation: _json(output.citation),
1123
- };
1124
- }
1125
- if (output.reasoningContent != null) {
1126
- return {
1127
- reasoningContent: de_ReasoningContentBlockDelta(__expectUnion(output.reasoningContent), context),
1128
- };
1129
- }
1130
- if (__expectString(output.text) !== undefined) {
1131
- return { text: __expectString(output.text) };
1132
- }
1133
- if (output.toolResult != null) {
1134
- return {
1135
- toolResult: _json(output.toolResult),
1136
- };
1137
- }
1138
- if (output.toolUse != null) {
1139
- return {
1140
- toolUse: _json(output.toolUse),
1141
- };
1142
- }
1143
- return { $unknown: Object.entries(output)[0] };
1144
- };
1145
- const de_ContentBlockDeltaEvent = (output, context) => {
1146
- return take(output, {
1147
- contentBlockIndex: __expectInt32,
1148
- delta: (_) => de_ContentBlockDelta(__expectUnion(_), context),
1149
- });
1150
- };
1151
- const de_ContentBlocks = (output, context) => {
1152
- const retVal = (output || [])
1153
- .filter((e) => e != null)
1154
- .map((entry) => {
1155
- return de_ContentBlock(__expectUnion(entry), context);
1156
- });
1157
- return retVal;
1158
- };
1159
- const de_ConverseOutput = (output, context) => {
1160
- if (output.message != null) {
1161
- return {
1162
- message: de_Message(output.message, context),
1163
- };
1164
- }
1165
- return { $unknown: Object.entries(output)[0] };
1166
- };
1167
- const de_ConverseStreamMetadataEvent = (output, context) => {
1168
- return take(output, {
1169
- metrics: _json,
1170
- performanceConfig: _json,
1171
- trace: (_) => de_ConverseStreamTrace(_, context),
1172
- usage: _json,
1173
- });
1174
- };
1175
- const de_ConverseStreamTrace = (output, context) => {
1176
- return take(output, {
1177
- guardrail: (_) => de_GuardrailTraceAssessment(_, context),
1178
- promptRouter: _json,
1179
- });
1180
- };
1181
- const de_ConverseTrace = (output, context) => {
1182
- return take(output, {
1183
- guardrail: (_) => de_GuardrailTraceAssessment(_, context),
1184
- promptRouter: _json,
1185
- });
1186
- };
1187
- const de_DocumentBlock = (output, context) => {
1188
- return take(output, {
1189
- citations: _json,
1190
- context: __expectString,
1191
- format: __expectString,
1192
- name: __expectString,
1193
- source: (_) => de_DocumentSource(__expectUnion(_), context),
1194
- });
1195
- };
1196
- const de_DocumentSource = (output, context) => {
1197
- if (output.bytes != null) {
1198
- return {
1199
- bytes: context.base64Decoder(output.bytes),
1200
- };
1201
- }
1202
- if (output.content != null) {
1203
- return {
1204
- content: _json(output.content),
1205
- };
1206
- }
1207
- if (output.s3Location != null) {
1208
- return {
1209
- s3Location: _json(output.s3Location),
1210
- };
1211
- }
1212
- if (__expectString(output.text) !== undefined) {
1213
- return { text: __expectString(output.text) };
1214
- }
1215
- return { $unknown: Object.entries(output)[0] };
1216
- };
1217
- const de_GuardrailAssessment = (output, context) => {
1218
- return take(output, {
1219
- automatedReasoningPolicy: (_) => de_GuardrailAutomatedReasoningPolicyAssessment(_, context),
1220
- contentPolicy: _json,
1221
- contextualGroundingPolicy: (_) => de_GuardrailContextualGroundingPolicyAssessment(_, context),
1222
- invocationMetrics: _json,
1223
- sensitiveInformationPolicy: _json,
1224
- topicPolicy: _json,
1225
- wordPolicy: _json,
1226
- });
1227
- };
1228
- const de_GuardrailAssessmentList = (output, context) => {
1229
- const retVal = (output || [])
1230
- .filter((e) => e != null)
1231
- .map((entry) => {
1232
- return de_GuardrailAssessment(entry, context);
1233
- });
1234
- return retVal;
1235
- };
1236
- const de_GuardrailAssessmentListMap = (output, context) => {
1237
- return Object.entries(output).reduce((acc, [key, value]) => {
1238
- if (value === null) {
1239
- return acc;
1240
- }
1241
- acc[key] = de_GuardrailAssessmentList(value, context);
1242
- return acc;
1243
- }, {});
1244
- };
1245
- const de_GuardrailAssessmentMap = (output, context) => {
1246
- return Object.entries(output).reduce((acc, [key, value]) => {
1247
- if (value === null) {
1248
- return acc;
1249
- }
1250
- acc[key] = de_GuardrailAssessment(value, context);
1251
- return acc;
1252
- }, {});
1253
- };
1254
- const de_GuardrailAutomatedReasoningFinding = (output, context) => {
1255
- if (output.impossible != null) {
1256
- return {
1257
- impossible: de_GuardrailAutomatedReasoningImpossibleFinding(output.impossible, context),
1258
- };
1259
- }
1260
- if (output.invalid != null) {
1261
- return {
1262
- invalid: de_GuardrailAutomatedReasoningInvalidFinding(output.invalid, context),
1263
- };
1264
- }
1265
- if (output.noTranslations != null) {
1266
- return {
1267
- noTranslations: _json(output.noTranslations),
1268
- };
1269
- }
1270
- if (output.satisfiable != null) {
1271
- return {
1272
- satisfiable: de_GuardrailAutomatedReasoningSatisfiableFinding(output.satisfiable, context),
1273
- };
1274
- }
1275
- if (output.tooComplex != null) {
1276
- return {
1277
- tooComplex: _json(output.tooComplex),
1278
- };
1279
- }
1280
- if (output.translationAmbiguous != null) {
1281
- return {
1282
- translationAmbiguous: de_GuardrailAutomatedReasoningTranslationAmbiguousFinding(output.translationAmbiguous, context),
1283
- };
1284
- }
1285
- if (output.valid != null) {
1286
- return {
1287
- valid: de_GuardrailAutomatedReasoningValidFinding(output.valid, context),
1288
- };
1289
- }
1290
- return { $unknown: Object.entries(output)[0] };
1291
- };
1292
- const de_GuardrailAutomatedReasoningFindingList = (output, context) => {
1293
- const retVal = (output || [])
1294
- .filter((e) => e != null)
1295
- .map((entry) => {
1296
- return de_GuardrailAutomatedReasoningFinding(__expectUnion(entry), context);
1297
- });
1298
- return retVal;
1299
- };
1300
- const de_GuardrailAutomatedReasoningImpossibleFinding = (output, context) => {
1301
- return take(output, {
1302
- contradictingRules: _json,
1303
- logicWarning: _json,
1304
- translation: (_) => de_GuardrailAutomatedReasoningTranslation(_, context),
1305
- });
1306
- };
1307
- const de_GuardrailAutomatedReasoningInvalidFinding = (output, context) => {
1308
- return take(output, {
1309
- contradictingRules: _json,
1310
- logicWarning: _json,
1311
- translation: (_) => de_GuardrailAutomatedReasoningTranslation(_, context),
1312
- });
1313
- };
1314
- const de_GuardrailAutomatedReasoningPolicyAssessment = (output, context) => {
1315
- return take(output, {
1316
- findings: (_) => de_GuardrailAutomatedReasoningFindingList(_, context),
1317
- });
1318
- };
1319
- const de_GuardrailAutomatedReasoningSatisfiableFinding = (output, context) => {
1320
- return take(output, {
1321
- claimsFalseScenario: _json,
1322
- claimsTrueScenario: _json,
1323
- logicWarning: _json,
1324
- translation: (_) => de_GuardrailAutomatedReasoningTranslation(_, context),
1325
- });
1326
- };
1327
- const de_GuardrailAutomatedReasoningTranslation = (output, context) => {
1328
- return take(output, {
1329
- claims: _json,
1330
- confidence: __limitedParseDouble,
1331
- premises: _json,
1332
- untranslatedClaims: _json,
1333
- untranslatedPremises: _json,
1334
- });
1335
- };
1336
- const de_GuardrailAutomatedReasoningTranslationAmbiguousFinding = (output, context) => {
1337
- return take(output, {
1338
- differenceScenarios: _json,
1339
- options: (_) => de_GuardrailAutomatedReasoningTranslationOptionList(_, context),
1340
- });
1341
- };
1342
- const de_GuardrailAutomatedReasoningTranslationList = (output, context) => {
1343
- const retVal = (output || [])
1344
- .filter((e) => e != null)
1345
- .map((entry) => {
1346
- return de_GuardrailAutomatedReasoningTranslation(entry, context);
1347
- });
1348
- return retVal;
1349
- };
1350
- const de_GuardrailAutomatedReasoningTranslationOption = (output, context) => {
1351
- return take(output, {
1352
- translations: (_) => de_GuardrailAutomatedReasoningTranslationList(_, context),
1353
- });
1354
- };
1355
- const de_GuardrailAutomatedReasoningTranslationOptionList = (output, context) => {
1356
- const retVal = (output || [])
1357
- .filter((e) => e != null)
1358
- .map((entry) => {
1359
- return de_GuardrailAutomatedReasoningTranslationOption(entry, context);
1360
- });
1361
- return retVal;
1362
- };
1363
- const de_GuardrailAutomatedReasoningValidFinding = (output, context) => {
1364
- return take(output, {
1365
- claimsTrueScenario: _json,
1366
- logicWarning: _json,
1367
- supportingRules: _json,
1368
- translation: (_) => de_GuardrailAutomatedReasoningTranslation(_, context),
1369
- });
1370
- };
1371
- const de_GuardrailContextualGroundingFilter = (output, context) => {
1372
- return take(output, {
1373
- action: __expectString,
1374
- detected: __expectBoolean,
1375
- score: __limitedParseDouble,
1376
- threshold: __limitedParseDouble,
1377
- type: __expectString,
1378
- });
1379
- };
1380
- const de_GuardrailContextualGroundingFilters = (output, context) => {
1381
- const retVal = (output || [])
1382
- .filter((e) => e != null)
1383
- .map((entry) => {
1384
- return de_GuardrailContextualGroundingFilter(entry, context);
1385
- });
1386
- return retVal;
1387
- };
1388
- const de_GuardrailContextualGroundingPolicyAssessment = (output, context) => {
1389
- return take(output, {
1390
- filters: (_) => de_GuardrailContextualGroundingFilters(_, context),
1391
- });
1392
- };
1393
- const de_GuardrailConverseContentBlock = (output, context) => {
1394
- if (output.image != null) {
1395
- return {
1396
- image: de_GuardrailConverseImageBlock(output.image, context),
1397
- };
1398
- }
1399
- if (output.text != null) {
1400
- return {
1401
- text: _json(output.text),
1402
- };
1403
- }
1404
- return { $unknown: Object.entries(output)[0] };
1405
- };
1406
- const de_GuardrailConverseImageBlock = (output, context) => {
1407
- return take(output, {
1408
- format: __expectString,
1409
- source: (_) => de_GuardrailConverseImageSource(__expectUnion(_), context),
1410
- });
1411
- };
1412
- const de_GuardrailConverseImageSource = (output, context) => {
1413
- if (output.bytes != null) {
1414
- return {
1415
- bytes: context.base64Decoder(output.bytes),
1416
- };
1417
- }
1418
- return { $unknown: Object.entries(output)[0] };
1419
- };
1420
- const de_GuardrailTraceAssessment = (output, context) => {
1421
- return take(output, {
1422
- actionReason: __expectString,
1423
- inputAssessment: (_) => de_GuardrailAssessmentMap(_, context),
1424
- modelOutput: _json,
1425
- outputAssessments: (_) => de_GuardrailAssessmentListMap(_, context),
1426
- });
1427
- };
1428
- const de_ImageBlock = (output, context) => {
1429
- return take(output, {
1430
- format: __expectString,
1431
- source: (_) => de_ImageSource(__expectUnion(_), context),
1432
- });
1433
- };
1434
- const de_ImageSource = (output, context) => {
1435
- if (output.bytes != null) {
1436
- return {
1437
- bytes: context.base64Decoder(output.bytes),
1438
- };
1439
- }
1440
- if (output.s3Location != null) {
1441
- return {
1442
- s3Location: _json(output.s3Location),
1443
- };
1444
- }
1445
- return { $unknown: Object.entries(output)[0] };
1446
- };
1447
- const de_Message = (output, context) => {
1448
- return take(output, {
1449
- content: (_) => de_ContentBlocks(_, context),
1450
- role: __expectString,
1451
- });
1452
- };
1453
- const de_MessageStopEvent = (output, context) => {
1454
- return take(output, {
1455
- additionalModelResponseFields: (_) => de_Document(_, context),
1456
- stopReason: __expectString,
1457
- });
1458
- };
1459
- const de_PayloadPart = (output, context) => {
1460
- return take(output, {
1461
- bytes: context.base64Decoder,
1462
- });
1463
- };
1464
- const de_ReasoningContentBlock = (output, context) => {
1465
- if (output.reasoningText != null) {
1466
- return {
1467
- reasoningText: _json(output.reasoningText),
1468
- };
1469
- }
1470
- if (output.redactedContent != null) {
1471
- return {
1472
- redactedContent: context.base64Decoder(output.redactedContent),
1473
- };
1474
- }
1475
- return { $unknown: Object.entries(output)[0] };
1476
- };
1477
- const de_ReasoningContentBlockDelta = (output, context) => {
1478
- if (output.redactedContent != null) {
1479
- return {
1480
- redactedContent: context.base64Decoder(output.redactedContent),
1481
- };
1482
- }
1483
- if (__expectString(output.signature) !== undefined) {
1484
- return { signature: __expectString(output.signature) };
1485
- }
1486
- if (__expectString(output.text) !== undefined) {
1487
- return { text: __expectString(output.text) };
1488
- }
1489
- return { $unknown: Object.entries(output)[0] };
1490
- };
1491
- const de_ToolResultBlock = (output, context) => {
1492
- return take(output, {
1493
- content: (_) => de_ToolResultContentBlocks(_, context),
1494
- status: __expectString,
1495
- toolUseId: __expectString,
1496
- type: __expectString,
1497
- });
1498
- };
1499
- const de_ToolResultContentBlock = (output, context) => {
1500
- if (output.document != null) {
1501
- return {
1502
- document: de_DocumentBlock(output.document, context),
1503
- };
1504
- }
1505
- if (output.image != null) {
1506
- return {
1507
- image: de_ImageBlock(output.image, context),
1508
- };
1509
- }
1510
- if (output.json != null) {
1511
- return {
1512
- json: de_Document(output.json, context),
1513
- };
1514
- }
1515
- if (__expectString(output.text) !== undefined) {
1516
- return { text: __expectString(output.text) };
1517
- }
1518
- if (output.video != null) {
1519
- return {
1520
- video: de_VideoBlock(output.video, context),
1521
- };
1522
- }
1523
- return { $unknown: Object.entries(output)[0] };
1524
- };
1525
- const de_ToolResultContentBlocks = (output, context) => {
1526
- const retVal = (output || [])
1527
- .filter((e) => e != null)
1528
- .map((entry) => {
1529
- return de_ToolResultContentBlock(__expectUnion(entry), context);
1530
- });
1531
- return retVal;
1532
- };
1533
- const de_ToolUseBlock = (output, context) => {
1534
- return take(output, {
1535
- input: (_) => de_Document(_, context),
1536
- name: __expectString,
1537
- toolUseId: __expectString,
1538
- type: __expectString,
1539
- });
1540
- };
1541
- const de_VideoBlock = (output, context) => {
1542
- return take(output, {
1543
- format: __expectString,
1544
- source: (_) => de_VideoSource(__expectUnion(_), context),
1545
- });
1546
- };
1547
- const de_VideoSource = (output, context) => {
1548
- if (output.bytes != null) {
1549
- return {
1550
- bytes: context.base64Decoder(output.bytes),
1551
- };
1552
- }
1553
- if (output.s3Location != null) {
1554
- return {
1555
- s3Location: _json(output.s3Location),
1556
- };
1557
- }
1558
- return { $unknown: Object.entries(output)[0] };
1559
- };
1560
- const de_Document = (output, context) => {
1561
- return output;
1562
- };
1563
- const deserializeMetadata = (output) => ({
1564
- httpStatusCode: output.statusCode,
1565
- requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
1566
- extendedRequestId: output.headers["x-amz-id-2"],
1567
- cfId: output.headers["x-amz-cf-id"],
1568
- });
1569
- const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
1570
- const _a = "accept";
1571
- const _cT = "contentType";
1572
- const _ct = "content-type";
1573
- const _gI = "guardrailIdentifier";
1574
- const _gV = "guardrailVersion";
1575
- const _mR = "maxResults";
1576
- const _nT = "nextToken";
1577
- const _pCL = "performanceConfigLatency";
1578
- const _sB = "sortBy";
1579
- const _sE = "statusEquals";
1580
- const _sO = "sortOrder";
1581
- const _sTA = "submitTimeAfter";
1582
- const _sTB = "submitTimeBefore";
1583
- const _t = "trace";
1584
- const _xaba = "x-amzn-bedrock-accept";
1585
- const _xabct = "x-amzn-bedrock-content-type";
1586
- const _xabg = "x-amzn-bedrock-guardrailidentifier";
1587
- const _xabg_ = "x-amzn-bedrock-guardrailversion";
1588
- const _xabpl = "x-amzn-bedrock-performanceconfig-latency";
1589
- const _xabt = "x-amzn-bedrock-trace";