Skip to content

Commit 57bdac0

Browse files
author
awstools
committed
feat(client-bedrock-runtime): Adds support for Audio Blocks and Streaming Image Output plus new Stop Reasons of malformed_model_output and malformed_tool_use.
1 parent f0544c3 commit 57bdac0

File tree

7 files changed

+648
-52
lines changed

7 files changed

+648
-52
lines changed

clients/client-bedrock-runtime/src/commands/ConverseCommand.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
5353
* bucketOwner: "STRING_VALUE",
5454
* },
5555
* },
56+
* error: { // ErrorBlock
57+
* message: "STRING_VALUE",
58+
* },
5659
* },
5760
* document: { // DocumentBlock
5861
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
@@ -85,6 +88,19 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
8588
* },
8689
* },
8790
* },
91+
* audio: { // AudioBlock
92+
* format: "mp3" || "opus" || "wav" || "aac" || "flac" || "mp4" || "ogg" || "mkv" || "mka" || "x-aac" || "m4a" || "mpeg" || "mpga" || "pcm" || "webm", // required
93+
* source: { // AudioSource Union: only one key present
94+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
95+
* s3Location: {
96+
* uri: "STRING_VALUE", // required
97+
* bucketOwner: "STRING_VALUE",
98+
* },
99+
* },
100+
* error: {
101+
* message: "STRING_VALUE",
102+
* },
103+
* },
88104
* toolUse: { // ToolUseBlock
89105
* toolUseId: "STRING_VALUE", // required
90106
* name: "STRING_VALUE", // required
@@ -106,16 +122,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
106122
* bucketOwner: "STRING_VALUE",
107123
* },
108124
* },
125+
* error: {
126+
* message: "STRING_VALUE",
127+
* },
109128
* },
110129
* document: {
111130
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
112131
* name: "STRING_VALUE", // required
113132
* source: {// Union: only one key present
114133
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
115-
* s3Location: {
116-
* uri: "STRING_VALUE", // required
117-
* bucketOwner: "STRING_VALUE",
118-
* },
134+
* s3Location: "<S3Location>",
119135
* text: "STRING_VALUE",
120136
* content: [
121137
* {// Union: only one key present
@@ -332,6 +348,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
332348
* // bucketOwner: "STRING_VALUE",
333349
* // },
334350
* // },
351+
* // error: { // ErrorBlock
352+
* // message: "STRING_VALUE",
353+
* // },
335354
* // },
336355
* // document: { // DocumentBlock
337356
* // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
@@ -364,6 +383,19 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
364383
* // },
365384
* // },
366385
* // },
386+
* // audio: { // AudioBlock
387+
* // format: "mp3" || "opus" || "wav" || "aac" || "flac" || "mp4" || "ogg" || "mkv" || "mka" || "x-aac" || "m4a" || "mpeg" || "mpga" || "pcm" || "webm", // required
388+
* // source: { // AudioSource Union: only one key present
389+
* // bytes: new Uint8Array(),
390+
* // s3Location: {
391+
* // uri: "STRING_VALUE", // required
392+
* // bucketOwner: "STRING_VALUE",
393+
* // },
394+
* // },
395+
* // error: {
396+
* // message: "STRING_VALUE",
397+
* // },
398+
* // },
367399
* // toolUse: { // ToolUseBlock
368400
* // toolUseId: "STRING_VALUE", // required
369401
* // name: "STRING_VALUE", // required
@@ -385,16 +417,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
385417
* // bucketOwner: "STRING_VALUE",
386418
* // },
387419
* // },
420+
* // error: {
421+
* // message: "STRING_VALUE",
422+
* // },
388423
* // },
389424
* // document: {
390425
* // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
391426
* // name: "STRING_VALUE", // required
392427
* // source: {// Union: only one key present
393428
* // bytes: new Uint8Array(),
394-
* // s3Location: {
395-
* // uri: "STRING_VALUE", // required
396-
* // bucketOwner: "STRING_VALUE",
397-
* // },
429+
* // s3Location: "<S3Location>",
398430
* // text: "STRING_VALUE",
399431
* // content: [
400432
* // {// Union: only one key present
@@ -515,7 +547,7 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
515547
* // ],
516548
* // },
517549
* // },
518-
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "guardrail_intervened" || "content_filtered" || "model_context_window_exceeded", // required
550+
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "guardrail_intervened" || "content_filtered" || "malformed_model_output" || "malformed_tool_use" || "model_context_window_exceeded", // required
519551
* // usage: { // TokenUsage
520552
* // inputTokens: Number("int"), // required
521553
* // outputTokens: Number("int"), // required

clients/client-bedrock-runtime/src/commands/ConverseStreamCommand.ts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
5353
* bucketOwner: "STRING_VALUE",
5454
* },
5555
* },
56+
* error: { // ErrorBlock
57+
* message: "STRING_VALUE",
58+
* },
5659
* },
5760
* document: { // DocumentBlock
5861
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
@@ -85,6 +88,19 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
8588
* },
8689
* },
8790
* },
91+
* audio: { // AudioBlock
92+
* format: "mp3" || "opus" || "wav" || "aac" || "flac" || "mp4" || "ogg" || "mkv" || "mka" || "x-aac" || "m4a" || "mpeg" || "mpga" || "pcm" || "webm", // required
93+
* source: { // AudioSource Union: only one key present
94+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
95+
* s3Location: {
96+
* uri: "STRING_VALUE", // required
97+
* bucketOwner: "STRING_VALUE",
98+
* },
99+
* },
100+
* error: {
101+
* message: "STRING_VALUE",
102+
* },
103+
* },
88104
* toolUse: { // ToolUseBlock
89105
* toolUseId: "STRING_VALUE", // required
90106
* name: "STRING_VALUE", // required
@@ -106,16 +122,16 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
106122
* bucketOwner: "STRING_VALUE",
107123
* },
108124
* },
125+
* error: {
126+
* message: "STRING_VALUE",
127+
* },
109128
* },
110129
* document: {
111130
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
112131
* name: "STRING_VALUE", // required
113132
* source: {// Union: only one key present
114133
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
115-
* s3Location: {
116-
* uri: "STRING_VALUE", // required
117-
* bucketOwner: "STRING_VALUE",
118-
* },
134+
* s3Location: "<S3Location>",
119135
* text: "STRING_VALUE",
120136
* content: [
121137
* {// Union: only one key present
@@ -334,6 +350,9 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
334350
* // type: "STRING_VALUE",
335351
* // status: "success" || "error",
336352
* // },
353+
* // image: { // ImageBlockStart
354+
* // format: "png" || "jpeg" || "gif" || "webp", // required
355+
* // },
337356
* // },
338357
* // contentBlockIndex: Number("int"), // required
339358
* // },
@@ -346,6 +365,7 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
346365
* // toolResult: [ // ToolResultBlocksDelta
347366
* // { // ToolResultBlockDelta Union: only one key present
348367
* // text: "STRING_VALUE",
368+
* // json: "DOCUMENT_VALUE",
349369
* // },
350370
* // ],
351371
* // reasoningContent: { // ReasoningContentBlockDelta Union: only one key present
@@ -388,14 +408,26 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
388408
* // },
389409
* // },
390410
* // },
411+
* // image: { // ImageBlockDelta
412+
* // source: { // ImageSource Union: only one key present
413+
* // bytes: new Uint8Array(),
414+
* // s3Location: { // S3Location
415+
* // uri: "STRING_VALUE", // required
416+
* // bucketOwner: "STRING_VALUE",
417+
* // },
418+
* // },
419+
* // error: { // ErrorBlock
420+
* // message: "STRING_VALUE",
421+
* // },
422+
* // },
391423
* // },
392424
* // contentBlockIndex: Number("int"), // required
393425
* // },
394426
* // contentBlockStop: { // ContentBlockStopEvent
395427
* // contentBlockIndex: Number("int"), // required
396428
* // },
397429
* // messageStop: { // MessageStopEvent
398-
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "guardrail_intervened" || "content_filtered" || "model_context_window_exceeded", // required
430+
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "guardrail_intervened" || "content_filtered" || "malformed_model_output" || "malformed_tool_use" || "model_context_window_exceeded", // required
399431
* // additionalModelResponseFields: "DOCUMENT_VALUE",
400432
* // },
401433
* // metadata: { // ConverseStreamMetadataEvent

clients/client-bedrock-runtime/src/commands/CountTokensCommand.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export interface CountTokensCommandOutput extends CountTokensResponse, __Metadat
5858
* bucketOwner: "STRING_VALUE",
5959
* },
6060
* },
61+
* error: { // ErrorBlock
62+
* message: "STRING_VALUE",
63+
* },
6164
* },
6265
* document: { // DocumentBlock
6366
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
@@ -90,6 +93,19 @@ export interface CountTokensCommandOutput extends CountTokensResponse, __Metadat
9093
* },
9194
* },
9295
* },
96+
* audio: { // AudioBlock
97+
* format: "mp3" || "opus" || "wav" || "aac" || "flac" || "mp4" || "ogg" || "mkv" || "mka" || "x-aac" || "m4a" || "mpeg" || "mpga" || "pcm" || "webm", // required
98+
* source: { // AudioSource Union: only one key present
99+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
100+
* s3Location: {
101+
* uri: "STRING_VALUE", // required
102+
* bucketOwner: "STRING_VALUE",
103+
* },
104+
* },
105+
* error: {
106+
* message: "STRING_VALUE",
107+
* },
108+
* },
93109
* toolUse: { // ToolUseBlock
94110
* toolUseId: "STRING_VALUE", // required
95111
* name: "STRING_VALUE", // required
@@ -111,16 +127,16 @@ export interface CountTokensCommandOutput extends CountTokensResponse, __Metadat
111127
* bucketOwner: "STRING_VALUE",
112128
* },
113129
* },
130+
* error: {
131+
* message: "STRING_VALUE",
132+
* },
114133
* },
115134
* document: {
116135
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md",
117136
* name: "STRING_VALUE", // required
118137
* source: {// Union: only one key present
119138
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
120-
* s3Location: {
121-
* uri: "STRING_VALUE", // required
122-
* bucketOwner: "STRING_VALUE",
123-
* },
139+
* s3Location: "<S3Location>",
124140
* text: "STRING_VALUE",
125141
* content: [
126142
* {// Union: only one key present

clients/client-bedrock-runtime/src/models/enums.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,32 @@ export const GuardrailTrace = {
357357
*/
358358
export type GuardrailTrace = (typeof GuardrailTrace)[keyof typeof GuardrailTrace];
359359

360+
/**
361+
* @public
362+
* @enum
363+
*/
364+
export const AudioFormat = {
365+
AAC: "aac",
366+
FLAC: "flac",
367+
M4A: "m4a",
368+
MKA: "mka",
369+
MKV: "mkv",
370+
MP3: "mp3",
371+
MP4: "mp4",
372+
MPEG: "mpeg",
373+
MPGA: "mpga",
374+
OGG: "ogg",
375+
OPUS: "opus",
376+
PCM: "pcm",
377+
WAV: "wav",
378+
WEBM: "webm",
379+
X_AAC: "x-aac",
380+
} as const;
381+
/**
382+
* @public
383+
*/
384+
export type AudioFormat = (typeof AudioFormat)[keyof typeof AudioFormat];
385+
360386
/**
361387
* @public
362388
* @enum
@@ -527,6 +553,8 @@ export const StopReason = {
527553
CONTENT_FILTERED: "content_filtered",
528554
END_TURN: "end_turn",
529555
GUARDRAIL_INTERVENED: "guardrail_intervened",
556+
MALFORMED_MODEL_OUTPUT: "malformed_model_output",
557+
MALFORMED_TOOL_USE: "malformed_tool_use",
530558
MAX_TOKENS: "max_tokens",
531559
MODEL_CONTEXT_WINDOW_EXCEEDED: "model_context_window_exceeded",
532560
STOP_SEQUENCE: "stop_sequence",

0 commit comments

Comments
 (0)