@aws-sdk/client-bedrock-runtime 3.583.0 → 3.587.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/dist-cjs/index.js +653 -31
- package/dist-es/BedrockRuntime.js +4 -0
- package/dist-es/commands/ConverseCommand.js +24 -0
- package/dist-es/commands/ConverseStreamCommand.js +29 -0
- package/dist-es/commands/index.js +2 -0
- package/dist-es/models/models_0.js +187 -16
- package/dist-es/protocols/Aws_restJson1.js +381 -6
- package/dist-types/BedrockRuntime.d.ts +14 -0
- package/dist-types/BedrockRuntimeClient.d.ts +4 -2
- package/dist-types/commands/ConverseCommand.d.ts +208 -0
- package/dist-types/commands/ConverseStreamCommand.d.ts +221 -0
- package/dist-types/commands/index.d.ts +2 -0
- package/dist-types/models/models_0.d.ts +1413 -108
- package/dist-types/protocols/Aws_restJson1.d.ts +18 -0
- package/dist-types/ts3.4/BedrockRuntime.d.ts +34 -0
- package/dist-types/ts3.4/BedrockRuntimeClient.d.ts +12 -0
- package/dist-types/ts3.4/commands/ConverseCommand.d.ts +35 -0
- package/dist-types/ts3.4/commands/ConverseStreamCommand.d.ts +38 -0
- package/dist-types/ts3.4/commands/index.d.ts +2 -0
- package/dist-types/ts3.4/models/models_0.d.ts +602 -33
- package/dist-types/ts3.4/protocols/Aws_restJson1.d.ts +24 -0
- package/package.json +18 -18
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
|
|
1
|
+
import { awsExpectUnion as __expectUnion, loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody, } from "@aws-sdk/core";
|
|
2
2
|
import { requestBuilder as rb } from "@smithy/core";
|
|
3
|
-
import { collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectString as __expectString, map, take, withBaseException, } from "@smithy/smithy-client";
|
|
3
|
+
import { _json, collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, map, serializeFloat as __serializeFloat, take, withBaseException, } from "@smithy/smithy-client";
|
|
4
4
|
import { BedrockRuntimeServiceException as __BaseException } from "../models/BedrockRuntimeServiceException";
|
|
5
|
-
import { AccessDeniedException, InternalServerException, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, ValidationException, } from "../models/models_0";
|
|
5
|
+
import { AccessDeniedException, ContentBlock, ImageSource, InternalServerException, ModelErrorException, ModelNotReadyException, ModelStreamErrorException, ModelTimeoutException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException, Tool, ToolInputSchema, ToolResultContentBlock, ValidationException, } from "../models/models_0";
|
|
6
|
+
export const se_ConverseCommand = async (input, context) => {
|
|
7
|
+
const b = rb(input, context);
|
|
8
|
+
const headers = {
|
|
9
|
+
"content-type": "application/json",
|
|
10
|
+
};
|
|
11
|
+
b.bp("/model/{modelId}/converse");
|
|
12
|
+
b.p("modelId", () => input.modelId, "{modelId}", false);
|
|
13
|
+
let body;
|
|
14
|
+
body = JSON.stringify(take(input, {
|
|
15
|
+
additionalModelRequestFields: (_) => se_Document(_, context),
|
|
16
|
+
additionalModelResponseFieldPaths: (_) => _json(_),
|
|
17
|
+
inferenceConfig: (_) => se_InferenceConfiguration(_, context),
|
|
18
|
+
messages: (_) => se_Messages(_, context),
|
|
19
|
+
system: (_) => _json(_),
|
|
20
|
+
toolConfig: (_) => se_ToolConfiguration(_, context),
|
|
21
|
+
}));
|
|
22
|
+
b.m("POST").h(headers).b(body);
|
|
23
|
+
return b.build();
|
|
24
|
+
};
|
|
25
|
+
export const se_ConverseStreamCommand = async (input, context) => {
|
|
26
|
+
const b = rb(input, context);
|
|
27
|
+
const headers = {
|
|
28
|
+
"content-type": "application/json",
|
|
29
|
+
};
|
|
30
|
+
b.bp("/model/{modelId}/converse-stream");
|
|
31
|
+
b.p("modelId", () => input.modelId, "{modelId}", false);
|
|
32
|
+
let body;
|
|
33
|
+
body = JSON.stringify(take(input, {
|
|
34
|
+
additionalModelRequestFields: (_) => se_Document(_, context),
|
|
35
|
+
additionalModelResponseFieldPaths: (_) => _json(_),
|
|
36
|
+
inferenceConfig: (_) => se_InferenceConfiguration(_, context),
|
|
37
|
+
messages: (_) => se_Messages(_, context),
|
|
38
|
+
system: (_) => _json(_),
|
|
39
|
+
toolConfig: (_) => se_ToolConfiguration(_, context),
|
|
40
|
+
}));
|
|
41
|
+
b.m("POST").h(headers).b(body);
|
|
42
|
+
return b.build();
|
|
43
|
+
};
|
|
6
44
|
export const se_InvokeModelCommand = async (input, context) => {
|
|
7
45
|
const b = rb(input, context);
|
|
8
46
|
const headers = map({}, isSerializableHeaderValue, {
|
|
@@ -39,6 +77,35 @@ export const se_InvokeModelWithResponseStreamCommand = async (input, context) =>
|
|
|
39
77
|
b.m("POST").h(headers).b(body);
|
|
40
78
|
return b.build();
|
|
41
79
|
};
|
|
80
|
+
export const de_ConverseCommand = async (output, context) => {
|
|
81
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
82
|
+
return de_CommandError(output, context);
|
|
83
|
+
}
|
|
84
|
+
const contents = map({
|
|
85
|
+
$metadata: deserializeMetadata(output),
|
|
86
|
+
});
|
|
87
|
+
const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
|
|
88
|
+
const doc = take(data, {
|
|
89
|
+
additionalModelResponseFields: (_) => de_Document(_, context),
|
|
90
|
+
metrics: _json,
|
|
91
|
+
output: (_) => de_ConverseOutput(__expectUnion(_), context),
|
|
92
|
+
stopReason: __expectString,
|
|
93
|
+
usage: _json,
|
|
94
|
+
});
|
|
95
|
+
Object.assign(contents, doc);
|
|
96
|
+
return contents;
|
|
97
|
+
};
|
|
98
|
+
export const de_ConverseStreamCommand = async (output, context) => {
|
|
99
|
+
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
100
|
+
return de_CommandError(output, context);
|
|
101
|
+
}
|
|
102
|
+
const contents = map({
|
|
103
|
+
$metadata: deserializeMetadata(output),
|
|
104
|
+
});
|
|
105
|
+
const data = output.body;
|
|
106
|
+
contents.stream = de_ConverseStreamOutput(data, context);
|
|
107
|
+
return contents;
|
|
108
|
+
};
|
|
42
109
|
export const de_InvokeModelCommand = async (output, context) => {
|
|
43
110
|
if (output.statusCode !== 200 && output.statusCode >= 300) {
|
|
44
111
|
return de_CommandError(output, context);
|
|
@@ -88,15 +155,15 @@ const de_CommandError = async (output, context) => {
|
|
|
88
155
|
case "ResourceNotFoundException":
|
|
89
156
|
case "com.amazonaws.bedrockruntime#ResourceNotFoundException":
|
|
90
157
|
throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
|
|
91
|
-
case "ServiceQuotaExceededException":
|
|
92
|
-
case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
|
|
93
|
-
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
94
158
|
case "ThrottlingException":
|
|
95
159
|
case "com.amazonaws.bedrockruntime#ThrottlingException":
|
|
96
160
|
throw await de_ThrottlingExceptionRes(parsedOutput, context);
|
|
97
161
|
case "ValidationException":
|
|
98
162
|
case "com.amazonaws.bedrockruntime#ValidationException":
|
|
99
163
|
throw await de_ValidationExceptionRes(parsedOutput, context);
|
|
164
|
+
case "ServiceQuotaExceededException":
|
|
165
|
+
case "com.amazonaws.bedrockruntime#ServiceQuotaExceededException":
|
|
166
|
+
throw await de_ServiceQuotaExceededExceptionRes(parsedOutput, context);
|
|
100
167
|
case "ModelStreamErrorException":
|
|
101
168
|
case "com.amazonaws.bedrockruntime#ModelStreamErrorException":
|
|
102
169
|
throw await de_ModelStreamErrorExceptionRes(parsedOutput, context);
|
|
@@ -244,6 +311,61 @@ const de_ValidationExceptionRes = async (parsedOutput, context) => {
|
|
|
244
311
|
});
|
|
245
312
|
return __decorateServiceException(exception, parsedOutput.body);
|
|
246
313
|
};
|
|
314
|
+
const de_ConverseStreamOutput = (output, context) => {
|
|
315
|
+
return context.eventStreamMarshaller.deserialize(output, async (event) => {
|
|
316
|
+
if (event["messageStart"] != null) {
|
|
317
|
+
return {
|
|
318
|
+
messageStart: await de_MessageStartEvent_event(event["messageStart"], context),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
if (event["contentBlockStart"] != null) {
|
|
322
|
+
return {
|
|
323
|
+
contentBlockStart: await de_ContentBlockStartEvent_event(event["contentBlockStart"], context),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
if (event["contentBlockDelta"] != null) {
|
|
327
|
+
return {
|
|
328
|
+
contentBlockDelta: await de_ContentBlockDeltaEvent_event(event["contentBlockDelta"], context),
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
if (event["contentBlockStop"] != null) {
|
|
332
|
+
return {
|
|
333
|
+
contentBlockStop: await de_ContentBlockStopEvent_event(event["contentBlockStop"], context),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
if (event["messageStop"] != null) {
|
|
337
|
+
return {
|
|
338
|
+
messageStop: await de_MessageStopEvent_event(event["messageStop"], context),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
if (event["metadata"] != null) {
|
|
342
|
+
return {
|
|
343
|
+
metadata: await de_ConverseStreamMetadataEvent_event(event["metadata"], context),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (event["internalServerException"] != null) {
|
|
347
|
+
return {
|
|
348
|
+
internalServerException: await de_InternalServerException_event(event["internalServerException"], context),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (event["modelStreamErrorException"] != null) {
|
|
352
|
+
return {
|
|
353
|
+
modelStreamErrorException: await de_ModelStreamErrorException_event(event["modelStreamErrorException"], context),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
if (event["validationException"] != null) {
|
|
357
|
+
return {
|
|
358
|
+
validationException: await de_ValidationException_event(event["validationException"], context),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
if (event["throttlingException"] != null) {
|
|
362
|
+
return {
|
|
363
|
+
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
return { $unknown: output };
|
|
367
|
+
});
|
|
368
|
+
};
|
|
247
369
|
const de_ResponseStream = (output, context) => {
|
|
248
370
|
return context.eventStreamMarshaller.deserialize(output, async (event) => {
|
|
249
371
|
if (event["chunk"] != null) {
|
|
@@ -279,6 +401,30 @@ const de_ResponseStream = (output, context) => {
|
|
|
279
401
|
return { $unknown: output };
|
|
280
402
|
});
|
|
281
403
|
};
|
|
404
|
+
const de_ContentBlockDeltaEvent_event = async (output, context) => {
|
|
405
|
+
const contents = {};
|
|
406
|
+
const data = await parseBody(output.body, context);
|
|
407
|
+
Object.assign(contents, _json(data));
|
|
408
|
+
return contents;
|
|
409
|
+
};
|
|
410
|
+
const de_ContentBlockStartEvent_event = async (output, context) => {
|
|
411
|
+
const contents = {};
|
|
412
|
+
const data = await parseBody(output.body, context);
|
|
413
|
+
Object.assign(contents, _json(data));
|
|
414
|
+
return contents;
|
|
415
|
+
};
|
|
416
|
+
const de_ContentBlockStopEvent_event = async (output, context) => {
|
|
417
|
+
const contents = {};
|
|
418
|
+
const data = await parseBody(output.body, context);
|
|
419
|
+
Object.assign(contents, _json(data));
|
|
420
|
+
return contents;
|
|
421
|
+
};
|
|
422
|
+
const de_ConverseStreamMetadataEvent_event = async (output, context) => {
|
|
423
|
+
const contents = {};
|
|
424
|
+
const data = await parseBody(output.body, context);
|
|
425
|
+
Object.assign(contents, _json(data));
|
|
426
|
+
return contents;
|
|
427
|
+
};
|
|
282
428
|
const de_InternalServerException_event = async (output, context) => {
|
|
283
429
|
const parsedOutput = {
|
|
284
430
|
...output,
|
|
@@ -286,6 +432,18 @@ const de_InternalServerException_event = async (output, context) => {
|
|
|
286
432
|
};
|
|
287
433
|
return de_InternalServerExceptionRes(parsedOutput, context);
|
|
288
434
|
};
|
|
435
|
+
const de_MessageStartEvent_event = async (output, context) => {
|
|
436
|
+
const contents = {};
|
|
437
|
+
const data = await parseBody(output.body, context);
|
|
438
|
+
Object.assign(contents, _json(data));
|
|
439
|
+
return contents;
|
|
440
|
+
};
|
|
441
|
+
const de_MessageStopEvent_event = async (output, context) => {
|
|
442
|
+
const contents = {};
|
|
443
|
+
const data = await parseBody(output.body, context);
|
|
444
|
+
Object.assign(contents, de_MessageStopEvent(data, context));
|
|
445
|
+
return contents;
|
|
446
|
+
};
|
|
289
447
|
const de_ModelStreamErrorException_event = async (output, context) => {
|
|
290
448
|
const parsedOutput = {
|
|
291
449
|
...output,
|
|
@@ -320,11 +478,228 @@ const de_ValidationException_event = async (output, context) => {
|
|
|
320
478
|
};
|
|
321
479
|
return de_ValidationExceptionRes(parsedOutput, context);
|
|
322
480
|
};
|
|
481
|
+
const se_ContentBlock = (input, context) => {
|
|
482
|
+
return ContentBlock.visit(input, {
|
|
483
|
+
image: (value) => ({ image: se_ImageBlock(value, context) }),
|
|
484
|
+
text: (value) => ({ text: value }),
|
|
485
|
+
toolResult: (value) => ({ toolResult: se_ToolResultBlock(value, context) }),
|
|
486
|
+
toolUse: (value) => ({ toolUse: se_ToolUseBlock(value, context) }),
|
|
487
|
+
_: (name, value) => ({ name: value }),
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
const se_ContentBlocks = (input, context) => {
|
|
491
|
+
return input
|
|
492
|
+
.filter((e) => e != null)
|
|
493
|
+
.map((entry) => {
|
|
494
|
+
return se_ContentBlock(entry, context);
|
|
495
|
+
});
|
|
496
|
+
};
|
|
497
|
+
const se_ImageBlock = (input, context) => {
|
|
498
|
+
return take(input, {
|
|
499
|
+
format: [],
|
|
500
|
+
source: (_) => se_ImageSource(_, context),
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
const se_ImageSource = (input, context) => {
|
|
504
|
+
return ImageSource.visit(input, {
|
|
505
|
+
bytes: (value) => ({ bytes: context.base64Encoder(value) }),
|
|
506
|
+
_: (name, value) => ({ name: value }),
|
|
507
|
+
});
|
|
508
|
+
};
|
|
509
|
+
const se_InferenceConfiguration = (input, context) => {
|
|
510
|
+
return take(input, {
|
|
511
|
+
maxTokens: [],
|
|
512
|
+
stopSequences: _json,
|
|
513
|
+
temperature: __serializeFloat,
|
|
514
|
+
topP: __serializeFloat,
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
const se_Message = (input, context) => {
|
|
518
|
+
return take(input, {
|
|
519
|
+
content: (_) => se_ContentBlocks(_, context),
|
|
520
|
+
role: [],
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
const se_Messages = (input, context) => {
|
|
524
|
+
return input
|
|
525
|
+
.filter((e) => e != null)
|
|
526
|
+
.map((entry) => {
|
|
527
|
+
return se_Message(entry, context);
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
const se_Tool = (input, context) => {
|
|
531
|
+
return Tool.visit(input, {
|
|
532
|
+
toolSpec: (value) => ({ toolSpec: se_ToolSpecification(value, context) }),
|
|
533
|
+
_: (name, value) => ({ name: value }),
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
const se_ToolConfiguration = (input, context) => {
|
|
537
|
+
return take(input, {
|
|
538
|
+
toolChoice: _json,
|
|
539
|
+
tools: (_) => se_Tools(_, context),
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
const se_ToolInputSchema = (input, context) => {
|
|
543
|
+
return ToolInputSchema.visit(input, {
|
|
544
|
+
json: (value) => ({ json: se_Document(value, context) }),
|
|
545
|
+
_: (name, value) => ({ name: value }),
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
const se_ToolResultBlock = (input, context) => {
|
|
549
|
+
return take(input, {
|
|
550
|
+
content: (_) => se_ToolResultContentBlocks(_, context),
|
|
551
|
+
status: [],
|
|
552
|
+
toolUseId: [],
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
const se_ToolResultContentBlock = (input, context) => {
|
|
556
|
+
return ToolResultContentBlock.visit(input, {
|
|
557
|
+
image: (value) => ({ image: se_ImageBlock(value, context) }),
|
|
558
|
+
json: (value) => ({ json: se_Document(value, context) }),
|
|
559
|
+
text: (value) => ({ text: value }),
|
|
560
|
+
_: (name, value) => ({ name: value }),
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
const se_ToolResultContentBlocks = (input, context) => {
|
|
564
|
+
return input
|
|
565
|
+
.filter((e) => e != null)
|
|
566
|
+
.map((entry) => {
|
|
567
|
+
return se_ToolResultContentBlock(entry, context);
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
const se_Tools = (input, context) => {
|
|
571
|
+
return input
|
|
572
|
+
.filter((e) => e != null)
|
|
573
|
+
.map((entry) => {
|
|
574
|
+
return se_Tool(entry, context);
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
const se_ToolSpecification = (input, context) => {
|
|
578
|
+
return take(input, {
|
|
579
|
+
description: [],
|
|
580
|
+
inputSchema: (_) => se_ToolInputSchema(_, context),
|
|
581
|
+
name: [],
|
|
582
|
+
});
|
|
583
|
+
};
|
|
584
|
+
const se_ToolUseBlock = (input, context) => {
|
|
585
|
+
return take(input, {
|
|
586
|
+
input: (_) => se_Document(_, context),
|
|
587
|
+
name: [],
|
|
588
|
+
toolUseId: [],
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
const se_Document = (input, context) => {
|
|
592
|
+
return input;
|
|
593
|
+
};
|
|
594
|
+
const de_ContentBlock = (output, context) => {
|
|
595
|
+
if (output.image != null) {
|
|
596
|
+
return {
|
|
597
|
+
image: de_ImageBlock(output.image, context),
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
if (__expectString(output.text) !== undefined) {
|
|
601
|
+
return { text: __expectString(output.text) };
|
|
602
|
+
}
|
|
603
|
+
if (output.toolResult != null) {
|
|
604
|
+
return {
|
|
605
|
+
toolResult: de_ToolResultBlock(output.toolResult, context),
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
if (output.toolUse != null) {
|
|
609
|
+
return {
|
|
610
|
+
toolUse: de_ToolUseBlock(output.toolUse, context),
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
return { $unknown: Object.entries(output)[0] };
|
|
614
|
+
};
|
|
615
|
+
const de_ContentBlocks = (output, context) => {
|
|
616
|
+
const retVal = (output || [])
|
|
617
|
+
.filter((e) => e != null)
|
|
618
|
+
.map((entry) => {
|
|
619
|
+
return de_ContentBlock(__expectUnion(entry), context);
|
|
620
|
+
});
|
|
621
|
+
return retVal;
|
|
622
|
+
};
|
|
623
|
+
const de_ConverseOutput = (output, context) => {
|
|
624
|
+
if (output.message != null) {
|
|
625
|
+
return {
|
|
626
|
+
message: de_Message(output.message, context),
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
return { $unknown: Object.entries(output)[0] };
|
|
630
|
+
};
|
|
631
|
+
const de_ImageBlock = (output, context) => {
|
|
632
|
+
return take(output, {
|
|
633
|
+
format: __expectString,
|
|
634
|
+
source: (_) => de_ImageSource(__expectUnion(_), context),
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
const de_ImageSource = (output, context) => {
|
|
638
|
+
if (output.bytes != null) {
|
|
639
|
+
return {
|
|
640
|
+
bytes: context.base64Decoder(output.bytes),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return { $unknown: Object.entries(output)[0] };
|
|
644
|
+
};
|
|
645
|
+
const de_Message = (output, context) => {
|
|
646
|
+
return take(output, {
|
|
647
|
+
content: (_) => de_ContentBlocks(_, context),
|
|
648
|
+
role: __expectString,
|
|
649
|
+
});
|
|
650
|
+
};
|
|
651
|
+
const de_MessageStopEvent = (output, context) => {
|
|
652
|
+
return take(output, {
|
|
653
|
+
additionalModelResponseFields: (_) => de_Document(_, context),
|
|
654
|
+
stopReason: __expectString,
|
|
655
|
+
});
|
|
656
|
+
};
|
|
323
657
|
const de_PayloadPart = (output, context) => {
|
|
324
658
|
return take(output, {
|
|
325
659
|
bytes: context.base64Decoder,
|
|
326
660
|
});
|
|
327
661
|
};
|
|
662
|
+
const de_ToolResultBlock = (output, context) => {
|
|
663
|
+
return take(output, {
|
|
664
|
+
content: (_) => de_ToolResultContentBlocks(_, context),
|
|
665
|
+
status: __expectString,
|
|
666
|
+
toolUseId: __expectString,
|
|
667
|
+
});
|
|
668
|
+
};
|
|
669
|
+
const de_ToolResultContentBlock = (output, context) => {
|
|
670
|
+
if (output.image != null) {
|
|
671
|
+
return {
|
|
672
|
+
image: de_ImageBlock(output.image, context),
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
if (output.json != null) {
|
|
676
|
+
return {
|
|
677
|
+
json: de_Document(output.json, context),
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (__expectString(output.text) !== undefined) {
|
|
681
|
+
return { text: __expectString(output.text) };
|
|
682
|
+
}
|
|
683
|
+
return { $unknown: Object.entries(output)[0] };
|
|
684
|
+
};
|
|
685
|
+
const de_ToolResultContentBlocks = (output, context) => {
|
|
686
|
+
const retVal = (output || [])
|
|
687
|
+
.filter((e) => e != null)
|
|
688
|
+
.map((entry) => {
|
|
689
|
+
return de_ToolResultContentBlock(__expectUnion(entry), context);
|
|
690
|
+
});
|
|
691
|
+
return retVal;
|
|
692
|
+
};
|
|
693
|
+
const de_ToolUseBlock = (output, context) => {
|
|
694
|
+
return take(output, {
|
|
695
|
+
input: (_) => de_Document(_, context),
|
|
696
|
+
name: __expectString,
|
|
697
|
+
toolUseId: __expectString,
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
const de_Document = (output, context) => {
|
|
701
|
+
return output;
|
|
702
|
+
};
|
|
328
703
|
const deserializeMetadata = (output) => ({
|
|
329
704
|
httpStatusCode: output.statusCode,
|
|
330
705
|
requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
|
|
2
2
|
import { BedrockRuntimeClient } from "./BedrockRuntimeClient";
|
|
3
|
+
import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
|
|
4
|
+
import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
|
|
3
5
|
import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
|
|
4
6
|
import { InvokeModelWithResponseStreamCommandInput, InvokeModelWithResponseStreamCommandOutput } from "./commands/InvokeModelWithResponseStreamCommand";
|
|
5
7
|
export interface BedrockRuntime {
|
|
8
|
+
/**
|
|
9
|
+
* @see {@link ConverseCommand}
|
|
10
|
+
*/
|
|
11
|
+
converse(args: ConverseCommandInput, options?: __HttpHandlerOptions): Promise<ConverseCommandOutput>;
|
|
12
|
+
converse(args: ConverseCommandInput, cb: (err: any, data?: ConverseCommandOutput) => void): void;
|
|
13
|
+
converse(args: ConverseCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: ConverseCommandOutput) => void): void;
|
|
14
|
+
/**
|
|
15
|
+
* @see {@link ConverseStreamCommand}
|
|
16
|
+
*/
|
|
17
|
+
converseStream(args: ConverseStreamCommandInput, options?: __HttpHandlerOptions): Promise<ConverseStreamCommandOutput>;
|
|
18
|
+
converseStream(args: ConverseStreamCommandInput, cb: (err: any, data?: ConverseStreamCommandOutput) => void): void;
|
|
19
|
+
converseStream(args: ConverseStreamCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: ConverseStreamCommandOutput) => void): void;
|
|
6
20
|
/**
|
|
7
21
|
* @see {@link InvokeModelCommand}
|
|
8
22
|
*/
|
|
@@ -8,6 +8,8 @@ import { HttpHandlerUserInput as __HttpHandlerUserInput } from "@smithy/protocol
|
|
|
8
8
|
import { Client as __Client, DefaultsMode as __DefaultsMode, SmithyConfiguration as __SmithyConfiguration, SmithyResolvedConfiguration as __SmithyResolvedConfiguration } from "@smithy/smithy-client";
|
|
9
9
|
import { AwsCredentialIdentityProvider, BodyLengthCalculator as __BodyLengthCalculator, CheckOptionalClientConfig as __CheckOptionalClientConfig, ChecksumConstructor as __ChecksumConstructor, Decoder as __Decoder, Encoder as __Encoder, EventStreamSerdeProvider as __EventStreamSerdeProvider, HashConstructor as __HashConstructor, HttpHandlerOptions as __HttpHandlerOptions, Logger as __Logger, Provider as __Provider, Provider, StreamCollector as __StreamCollector, UrlParser as __UrlParser, UserAgent as __UserAgent } from "@smithy/types";
|
|
10
10
|
import { HttpAuthSchemeInputConfig, HttpAuthSchemeResolvedConfig } from "./auth/httpAuthSchemeProvider";
|
|
11
|
+
import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
|
|
12
|
+
import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
|
|
11
13
|
import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
|
|
12
14
|
import { InvokeModelWithResponseStreamCommandInput, InvokeModelWithResponseStreamCommandOutput } from "./commands/InvokeModelWithResponseStreamCommand";
|
|
13
15
|
import { ClientInputEndpointParameters, ClientResolvedEndpointParameters, EndpointParameters } from "./endpoint/EndpointParameters";
|
|
@@ -16,11 +18,11 @@ export { __Client };
|
|
|
16
18
|
/**
|
|
17
19
|
* @public
|
|
18
20
|
*/
|
|
19
|
-
export type ServiceInputTypes = InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput;
|
|
21
|
+
export type ServiceInputTypes = ConverseCommandInput | ConverseStreamCommandInput | InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput;
|
|
20
22
|
/**
|
|
21
23
|
* @public
|
|
22
24
|
*/
|
|
23
|
-
export type ServiceOutputTypes = InvokeModelCommandOutput | InvokeModelWithResponseStreamCommandOutput;
|
|
25
|
+
export type ServiceOutputTypes = ConverseCommandOutput | ConverseStreamCommandOutput | InvokeModelCommandOutput | InvokeModelWithResponseStreamCommandOutput;
|
|
24
26
|
/**
|
|
25
27
|
* @public
|
|
26
28
|
*/
|