Skip to content

Commit 25f581e

Browse files
author
awstools
committed
feat(client-bedrock-runtime): You can now reference images and documents stored in Amazon S3 when using InvokeModel and Converse APIs with Amazon Nova Lite and Nova Pro. This enables direct integration of S3-stored multimedia assets in your model requests without manual downloading or base64 encoding.
1 parent f48ef14 commit 25f581e

File tree

5 files changed

+132
-38
lines changed

5 files changed

+132
-38
lines changed

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,28 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
7575
* format: "png" || "jpeg" || "gif" || "webp", // required
7676
* source: { // ImageSource Union: only one key present
7777
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
78+
* s3Location: { // S3Location
79+
* uri: "STRING_VALUE", // required
80+
* bucketOwner: "STRING_VALUE",
81+
* },
7882
* },
7983
* },
8084
* document: { // DocumentBlock
8185
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
8286
* name: "STRING_VALUE", // required
8387
* source: { // DocumentSource Union: only one key present
8488
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
89+
* s3Location: {
90+
* uri: "STRING_VALUE", // required
91+
* bucketOwner: "STRING_VALUE",
92+
* },
8593
* },
8694
* },
8795
* video: { // VideoBlock
8896
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
8997
* source: { // VideoSource Union: only one key present
9098
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
91-
* s3Location: { // S3Location
99+
* s3Location: {
92100
* uri: "STRING_VALUE", // required
93101
* bucketOwner: "STRING_VALUE",
94102
* },
@@ -109,23 +117,28 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
109117
* format: "png" || "jpeg" || "gif" || "webp", // required
110118
* source: {// Union: only one key present
111119
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
120+
* s3Location: {
121+
* uri: "STRING_VALUE", // required
122+
* bucketOwner: "STRING_VALUE",
123+
* },
112124
* },
113125
* },
114126
* document: {
115127
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
116128
* name: "STRING_VALUE", // required
117129
* source: {// Union: only one key present
118130
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
131+
* s3Location: {
132+
* uri: "STRING_VALUE", // required
133+
* bucketOwner: "STRING_VALUE",
134+
* },
119135
* },
120136
* },
121137
* video: {
122138
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
123139
* source: {// Union: only one key present
124140
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
125-
* s3Location: {
126-
* uri: "STRING_VALUE", // required
127-
* bucketOwner: "STRING_VALUE",
128-
* },
141+
* s3Location: "<S3Location>",
129142
* },
130143
* },
131144
* },
@@ -245,20 +258,28 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
245258
* // format: "png" || "jpeg" || "gif" || "webp", // required
246259
* // source: { // ImageSource Union: only one key present
247260
* // bytes: new Uint8Array(),
261+
* // s3Location: { // S3Location
262+
* // uri: "STRING_VALUE", // required
263+
* // bucketOwner: "STRING_VALUE",
264+
* // },
248265
* // },
249266
* // },
250267
* // document: { // DocumentBlock
251268
* // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
252269
* // name: "STRING_VALUE", // required
253270
* // source: { // DocumentSource Union: only one key present
254271
* // bytes: new Uint8Array(),
272+
* // s3Location: {
273+
* // uri: "STRING_VALUE", // required
274+
* // bucketOwner: "STRING_VALUE",
275+
* // },
255276
* // },
256277
* // },
257278
* // video: { // VideoBlock
258279
* // format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
259280
* // source: { // VideoSource Union: only one key present
260281
* // bytes: new Uint8Array(),
261-
* // s3Location: { // S3Location
282+
* // s3Location: {
262283
* // uri: "STRING_VALUE", // required
263284
* // bucketOwner: "STRING_VALUE",
264285
* // },
@@ -279,23 +300,28 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
279300
* // format: "png" || "jpeg" || "gif" || "webp", // required
280301
* // source: {// Union: only one key present
281302
* // bytes: new Uint8Array(),
303+
* // s3Location: {
304+
* // uri: "STRING_VALUE", // required
305+
* // bucketOwner: "STRING_VALUE",
306+
* // },
282307
* // },
283308
* // },
284309
* // document: {
285310
* // format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
286311
* // name: "STRING_VALUE", // required
287312
* // source: {// Union: only one key present
288313
* // bytes: new Uint8Array(),
314+
* // s3Location: {
315+
* // uri: "STRING_VALUE", // required
316+
* // bucketOwner: "STRING_VALUE",
317+
* // },
289318
* // },
290319
* // },
291320
* // video: {
292321
* // format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
293322
* // source: {// Union: only one key present
294323
* // bytes: new Uint8Array(),
295-
* // s3Location: {
296-
* // uri: "STRING_VALUE", // required
297-
* // bucketOwner: "STRING_VALUE",
298-
* // },
324+
* // s3Location: "<S3Location>",
299325
* // },
300326
* // },
301327
* // },

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,28 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
8181
* format: "png" || "jpeg" || "gif" || "webp", // required
8282
* source: { // ImageSource Union: only one key present
8383
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
84+
* s3Location: { // S3Location
85+
* uri: "STRING_VALUE", // required
86+
* bucketOwner: "STRING_VALUE",
87+
* },
8488
* },
8589
* },
8690
* document: { // DocumentBlock
8791
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
8892
* name: "STRING_VALUE", // required
8993
* source: { // DocumentSource Union: only one key present
9094
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
95+
* s3Location: {
96+
* uri: "STRING_VALUE", // required
97+
* bucketOwner: "STRING_VALUE",
98+
* },
9199
* },
92100
* },
93101
* video: { // VideoBlock
94102
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
95103
* source: { // VideoSource Union: only one key present
96104
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
97-
* s3Location: { // S3Location
105+
* s3Location: {
98106
* uri: "STRING_VALUE", // required
99107
* bucketOwner: "STRING_VALUE",
100108
* },
@@ -115,23 +123,28 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
115123
* format: "png" || "jpeg" || "gif" || "webp", // required
116124
* source: {// Union: only one key present
117125
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
126+
* s3Location: {
127+
* uri: "STRING_VALUE", // required
128+
* bucketOwner: "STRING_VALUE",
129+
* },
118130
* },
119131
* },
120132
* document: {
121133
* format: "pdf" || "csv" || "doc" || "docx" || "xls" || "xlsx" || "html" || "txt" || "md", // required
122134
* name: "STRING_VALUE", // required
123135
* source: {// Union: only one key present
124136
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
137+
* s3Location: {
138+
* uri: "STRING_VALUE", // required
139+
* bucketOwner: "STRING_VALUE",
140+
* },
125141
* },
126142
* },
127143
* video: {
128144
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
129145
* source: {// Union: only one key present
130146
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
131-
* s3Location: {
132-
* uri: "STRING_VALUE", // required
133-
* bucketOwner: "STRING_VALUE",
134-
* },
147+
* s3Location: "<S3Location>",
135148
* },
136149
* },
137150
* },

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

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,11 +1629,32 @@ export const DocumentFormat = {
16291629
*/
16301630
export type DocumentFormat = (typeof DocumentFormat)[keyof typeof DocumentFormat];
16311631

1632+
/**
1633+
* <p>A storage location in an Amazon S3 bucket.</p>
1634+
* @public
1635+
*/
1636+
export interface S3Location {
1637+
/**
1638+
* <p>An object URI starting with <code>s3://</code>.</p>
1639+
* @public
1640+
*/
1641+
uri: string | undefined;
1642+
1643+
/**
1644+
* <p>If the bucket belongs to another AWS account, specify that account's ID.</p>
1645+
* @public
1646+
*/
1647+
bucketOwner?: string | undefined;
1648+
}
1649+
16321650
/**
16331651
* <p>Contains the content of a document.</p>
16341652
* @public
16351653
*/
1636-
export type DocumentSource = DocumentSource.BytesMember | DocumentSource.$UnknownMember;
1654+
export type DocumentSource =
1655+
| DocumentSource.BytesMember
1656+
| DocumentSource.S3LocationMember
1657+
| DocumentSource.$UnknownMember;
16371658

16381659
/**
16391660
* @public
@@ -1645,6 +1666,17 @@ export namespace DocumentSource {
16451666
*/
16461667
export interface BytesMember {
16471668
bytes: Uint8Array;
1669+
s3Location?: never;
1670+
$unknown?: never;
1671+
}
1672+
1673+
/**
1674+
* <p>The location of a document object in an Amazon S3 bucket. To see which models support S3 uploads, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html">Supported models and features for Converse</a>.</p>
1675+
* @public
1676+
*/
1677+
export interface S3LocationMember {
1678+
bytes?: never;
1679+
s3Location: S3Location;
16481680
$unknown?: never;
16491681
}
16501682

@@ -1653,16 +1685,19 @@ export namespace DocumentSource {
16531685
*/
16541686
export interface $UnknownMember {
16551687
bytes?: never;
1688+
s3Location?: never;
16561689
$unknown: [string, any];
16571690
}
16581691

16591692
export interface Visitor<T> {
16601693
bytes: (value: Uint8Array) => T;
1694+
s3Location: (value: S3Location) => T;
16611695
_: (name: string, value: any) => T;
16621696
}
16631697

16641698
export const visit = <T>(value: DocumentSource, visitor: Visitor<T>): T => {
16651699
if (value.bytes !== undefined) return visitor.bytes(value.bytes);
1700+
if (value.s3Location !== undefined) return visitor.s3Location(value.s3Location);
16661701
return visitor._(value.$unknown[0], value.$unknown[1]);
16671702
};
16681703
}
@@ -1895,7 +1930,7 @@ export type ImageFormat = (typeof ImageFormat)[keyof typeof ImageFormat];
18951930
* <p>The source for an image.</p>
18961931
* @public
18971932
*/
1898-
export type ImageSource = ImageSource.BytesMember | ImageSource.$UnknownMember;
1933+
export type ImageSource = ImageSource.BytesMember | ImageSource.S3LocationMember | ImageSource.$UnknownMember;
18991934

19001935
/**
19011936
* @public
@@ -1907,6 +1942,17 @@ export namespace ImageSource {
19071942
*/
19081943
export interface BytesMember {
19091944
bytes: Uint8Array;
1945+
s3Location?: never;
1946+
$unknown?: never;
1947+
}
1948+
1949+
/**
1950+
* <p>The location of an image object in an Amazon S3 bucket. To see which models support S3 uploads, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html">Supported models and features for Converse</a>.</p>
1951+
* @public
1952+
*/
1953+
export interface S3LocationMember {
1954+
bytes?: never;
1955+
s3Location: S3Location;
19101956
$unknown?: never;
19111957
}
19121958

@@ -1915,16 +1961,19 @@ export namespace ImageSource {
19151961
*/
19161962
export interface $UnknownMember {
19171963
bytes?: never;
1964+
s3Location?: never;
19181965
$unknown: [string, any];
19191966
}
19201967

19211968
export interface Visitor<T> {
19221969
bytes: (value: Uint8Array) => T;
1970+
s3Location: (value: S3Location) => T;
19231971
_: (name: string, value: any) => T;
19241972
}
19251973

19261974
export const visit = <T>(value: ImageSource, visitor: Visitor<T>): T => {
19271975
if (value.bytes !== undefined) return visitor.bytes(value.bytes);
1976+
if (value.s3Location !== undefined) return visitor.s3Location(value.s3Location);
19281977
return visitor._(value.$unknown[0], value.$unknown[1]);
19291978
};
19301979
}
@@ -2041,24 +2090,6 @@ export const VideoFormat = {
20412090
*/
20422091
export type VideoFormat = (typeof VideoFormat)[keyof typeof VideoFormat];
20432092

2044-
/**
2045-
* <p>A storage location in an S3 bucket.</p>
2046-
* @public
2047-
*/
2048-
export interface S3Location {
2049-
/**
2050-
* <p>An object URI starting with <code>s3://</code>.</p>
2051-
* @public
2052-
*/
2053-
uri: string | undefined;
2054-
2055-
/**
2056-
* <p>If the bucket belongs to another AWS account, specify that account's ID.</p>
2057-
* @public
2058-
*/
2059-
bucketOwner?: string | undefined;
2060-
}
2061-
20622093
/**
20632094
* <p>A video source. You can upload a smaller video as a base64-encoded string as
20642095
* long as the encoded file is less than 25MB. You can also transfer videos up to 1GB in size
@@ -2082,7 +2113,7 @@ export namespace VideoSource {
20822113
}
20832114

20842115
/**
2085-
* <p>The location of a video object in an S3 bucket.</p>
2116+
* <p>The location of a video object in an Amazon S3 bucket. To see which models support S3 uploads, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html">Supported models and features for Converse</a>.</p>
20862117
* @public
20872118
*/
20882119
export interface S3LocationMember {

clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,7 @@ const se_DocumentBlock = (input: DocumentBlock, context: __SerdeContext): any =>
12351235
const se_DocumentSource = (input: DocumentSource, context: __SerdeContext): any => {
12361236
return DocumentSource.visit(input, {
12371237
bytes: (value) => ({ bytes: context.base64Encoder(value) }),
1238+
s3Location: (value) => ({ s3Location: _json(value) }),
12381239
_: (name, value) => ({ [name]: value } as any),
12391240
});
12401241
};
@@ -1340,6 +1341,7 @@ const se_ImageBlock = (input: ImageBlock, context: __SerdeContext): any => {
13401341
const se_ImageSource = (input: ImageSource, context: __SerdeContext): any => {
13411342
return ImageSource.visit(input, {
13421343
bytes: (value) => ({ bytes: context.base64Encoder(value) }),
1344+
s3Location: (value) => ({ s3Location: _json(value) }),
13431345
_: (name, value) => ({ [name]: value } as any),
13441346
});
13451347
};
@@ -1778,6 +1780,11 @@ const de_DocumentSource = (output: any, context: __SerdeContext): DocumentSource
17781780
bytes: context.base64Decoder(output.bytes),
17791781
};
17801782
}
1783+
if (output.s3Location != null) {
1784+
return {
1785+
s3Location: _json(output.s3Location),
1786+
};
1787+
}
17811788
return { $unknown: Object.entries(output)[0] };
17821789
};
17831790

@@ -1996,6 +2003,11 @@ const de_ImageSource = (output: any, context: __SerdeContext): ImageSource => {
19962003
bytes: context.base64Decoder(output.bytes),
19972004
};
19982005
}
2006+
if (output.s3Location != null) {
2007+
return {
2008+
s3Location: _json(output.s3Location),
2009+
};
2010+
}
19992011
return { $unknown: Object.entries(output)[0] };
20002012
};
20012013

0 commit comments

Comments
 (0)