Skip to content

Commit 9169d69

Browse files
author
awstools
committed
feat(client-bedrock-runtime): Added support for Async Invoke Operations Start, List and Get. Support for invocation logs with requestMetadata field in Converse, ConverseStream, Invoke and InvokeStream. Video content blocks in Converse/ConverseStream accept raw bytes or S3 URI.
1 parent d8beae2 commit 9169d69

18 files changed

+2575
-200
lines changed

clients/client-bedrock-runtime/README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ using your favorite package manager:
2323

2424
The AWS SDK is modulized by clients and commands.
2525
To send a request, you only need to import the `BedrockRuntimeClient` and
26-
the commands you need, for example `ConverseCommand`:
26+
the commands you need, for example `ListAsyncInvokesCommand`:
2727

2828
```js
2929
// ES5 example
30-
const { BedrockRuntimeClient, ConverseCommand } = require("@aws-sdk/client-bedrock-runtime");
30+
const { BedrockRuntimeClient, ListAsyncInvokesCommand } = require("@aws-sdk/client-bedrock-runtime");
3131
```
3232

3333
```ts
3434
// ES6+ example
35-
import { BedrockRuntimeClient, ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
35+
import { BedrockRuntimeClient, ListAsyncInvokesCommand } from "@aws-sdk/client-bedrock-runtime";
3636
```
3737

3838
### Usage
@@ -51,7 +51,7 @@ const client = new BedrockRuntimeClient({ region: "REGION" });
5151
const params = {
5252
/** input parameters */
5353
};
54-
const command = new ConverseCommand(params);
54+
const command = new ListAsyncInvokesCommand(params);
5555
```
5656

5757
#### Async/await
@@ -130,15 +130,15 @@ const client = new AWS.BedrockRuntime({ region: "REGION" });
130130

131131
// async/await.
132132
try {
133-
const data = await client.converse(params);
133+
const data = await client.listAsyncInvokes(params);
134134
// process data.
135135
} catch (error) {
136136
// error handling.
137137
}
138138

139139
// Promises.
140140
client
141-
.converse(params)
141+
.listAsyncInvokes(params)
142142
.then((data) => {
143143
// process data.
144144
})
@@ -147,7 +147,7 @@ client
147147
});
148148

149149
// callbacks.
150-
client.converse(params, (err, data) => {
150+
client.listAsyncInvokes(params, (err, data) => {
151151
// process err and data.
152152
});
153153
```
@@ -226,6 +226,14 @@ ConverseStream
226226

227227
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/ConverseStreamCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ConverseStreamCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ConverseStreamCommandOutput/)
228228

229+
</details>
230+
<details>
231+
<summary>
232+
GetAsyncInvoke
233+
</summary>
234+
235+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/GetAsyncInvokeCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/GetAsyncInvokeCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/GetAsyncInvokeCommandOutput/)
236+
229237
</details>
230238
<details>
231239
<summary>
@@ -243,3 +251,19 @@ InvokeModelWithResponseStream
243251
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/InvokeModelWithResponseStreamCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/InvokeModelWithResponseStreamCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/InvokeModelWithResponseStreamCommandOutput/)
244252

245253
</details>
254+
<details>
255+
<summary>
256+
ListAsyncInvokes
257+
</summary>
258+
259+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/ListAsyncInvokesCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ListAsyncInvokesCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/ListAsyncInvokesCommandOutput/)
260+
261+
</details>
262+
<details>
263+
<summary>
264+
StartAsyncInvoke
265+
</summary>
266+
267+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/command/StartAsyncInvokeCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/StartAsyncInvokeCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-bedrock-runtime/Interface/StartAsyncInvokeCommandOutput/)
268+
269+
</details>

clients/client-bedrock-runtime/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
"@smithy/util-retry": "^3.0.10",
6363
"@smithy/util-stream": "^3.3.1",
6464
"@smithy/util-utf8": "^3.0.0",
65-
"tslib": "^2.6.2"
65+
"@types/uuid": "^9.0.1",
66+
"tslib": "^2.6.2",
67+
"uuid": "^9.0.1"
6668
},
6769
"devDependencies": {
6870
"@tsconfig/node16": "16.1.3",

clients/client-bedrock-runtime/src/BedrockRuntime.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,37 @@ import {
1414
ConverseStreamCommandInput,
1515
ConverseStreamCommandOutput,
1616
} from "./commands/ConverseStreamCommand";
17+
import {
18+
GetAsyncInvokeCommand,
19+
GetAsyncInvokeCommandInput,
20+
GetAsyncInvokeCommandOutput,
21+
} from "./commands/GetAsyncInvokeCommand";
1722
import { InvokeModelCommand, InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
1823
import {
1924
InvokeModelWithResponseStreamCommand,
2025
InvokeModelWithResponseStreamCommandInput,
2126
InvokeModelWithResponseStreamCommandOutput,
2227
} from "./commands/InvokeModelWithResponseStreamCommand";
28+
import {
29+
ListAsyncInvokesCommand,
30+
ListAsyncInvokesCommandInput,
31+
ListAsyncInvokesCommandOutput,
32+
} from "./commands/ListAsyncInvokesCommand";
33+
import {
34+
StartAsyncInvokeCommand,
35+
StartAsyncInvokeCommandInput,
36+
StartAsyncInvokeCommandOutput,
37+
} from "./commands/StartAsyncInvokeCommand";
2338

2439
const commands = {
2540
ApplyGuardrailCommand,
2641
ConverseCommand,
2742
ConverseStreamCommand,
43+
GetAsyncInvokeCommand,
2844
InvokeModelCommand,
2945
InvokeModelWithResponseStreamCommand,
46+
ListAsyncInvokesCommand,
47+
StartAsyncInvokeCommand,
3048
};
3149

3250
export interface BedrockRuntime {
@@ -69,6 +87,20 @@ export interface BedrockRuntime {
6987
cb: (err: any, data?: ConverseStreamCommandOutput) => void
7088
): void;
7189

90+
/**
91+
* @see {@link GetAsyncInvokeCommand}
92+
*/
93+
getAsyncInvoke(
94+
args: GetAsyncInvokeCommandInput,
95+
options?: __HttpHandlerOptions
96+
): Promise<GetAsyncInvokeCommandOutput>;
97+
getAsyncInvoke(args: GetAsyncInvokeCommandInput, cb: (err: any, data?: GetAsyncInvokeCommandOutput) => void): void;
98+
getAsyncInvoke(
99+
args: GetAsyncInvokeCommandInput,
100+
options: __HttpHandlerOptions,
101+
cb: (err: any, data?: GetAsyncInvokeCommandOutput) => void
102+
): void;
103+
72104
/**
73105
* @see {@link InvokeModelCommand}
74106
*/
@@ -96,6 +128,41 @@ export interface BedrockRuntime {
96128
options: __HttpHandlerOptions,
97129
cb: (err: any, data?: InvokeModelWithResponseStreamCommandOutput) => void
98130
): void;
131+
132+
/**
133+
* @see {@link ListAsyncInvokesCommand}
134+
*/
135+
listAsyncInvokes(): Promise<ListAsyncInvokesCommandOutput>;
136+
listAsyncInvokes(
137+
args: ListAsyncInvokesCommandInput,
138+
options?: __HttpHandlerOptions
139+
): Promise<ListAsyncInvokesCommandOutput>;
140+
listAsyncInvokes(
141+
args: ListAsyncInvokesCommandInput,
142+
cb: (err: any, data?: ListAsyncInvokesCommandOutput) => void
143+
): void;
144+
listAsyncInvokes(
145+
args: ListAsyncInvokesCommandInput,
146+
options: __HttpHandlerOptions,
147+
cb: (err: any, data?: ListAsyncInvokesCommandOutput) => void
148+
): void;
149+
150+
/**
151+
* @see {@link StartAsyncInvokeCommand}
152+
*/
153+
startAsyncInvoke(
154+
args: StartAsyncInvokeCommandInput,
155+
options?: __HttpHandlerOptions
156+
): Promise<StartAsyncInvokeCommandOutput>;
157+
startAsyncInvoke(
158+
args: StartAsyncInvokeCommandInput,
159+
cb: (err: any, data?: StartAsyncInvokeCommandOutput) => void
160+
): void;
161+
startAsyncInvoke(
162+
args: StartAsyncInvokeCommandInput,
163+
options: __HttpHandlerOptions,
164+
cb: (err: any, data?: StartAsyncInvokeCommandOutput) => void
165+
): void;
99166
}
100167

101168
/**

clients/client-bedrock-runtime/src/BedrockRuntimeClient.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ import {
6262
import { ApplyGuardrailCommandInput, ApplyGuardrailCommandOutput } from "./commands/ApplyGuardrailCommand";
6363
import { ConverseCommandInput, ConverseCommandOutput } from "./commands/ConverseCommand";
6464
import { ConverseStreamCommandInput, ConverseStreamCommandOutput } from "./commands/ConverseStreamCommand";
65+
import { GetAsyncInvokeCommandInput, GetAsyncInvokeCommandOutput } from "./commands/GetAsyncInvokeCommand";
6566
import { InvokeModelCommandInput, InvokeModelCommandOutput } from "./commands/InvokeModelCommand";
6667
import {
6768
InvokeModelWithResponseStreamCommandInput,
6869
InvokeModelWithResponseStreamCommandOutput,
6970
} from "./commands/InvokeModelWithResponseStreamCommand";
71+
import { ListAsyncInvokesCommandInput, ListAsyncInvokesCommandOutput } from "./commands/ListAsyncInvokesCommand";
72+
import { StartAsyncInvokeCommandInput, StartAsyncInvokeCommandOutput } from "./commands/StartAsyncInvokeCommand";
7073
import {
7174
ClientInputEndpointParameters,
7275
ClientResolvedEndpointParameters,
@@ -85,8 +88,11 @@ export type ServiceInputTypes =
8588
| ApplyGuardrailCommandInput
8689
| ConverseCommandInput
8790
| ConverseStreamCommandInput
91+
| GetAsyncInvokeCommandInput
8892
| InvokeModelCommandInput
89-
| InvokeModelWithResponseStreamCommandInput;
93+
| InvokeModelWithResponseStreamCommandInput
94+
| ListAsyncInvokesCommandInput
95+
| StartAsyncInvokeCommandInput;
9096

9197
/**
9298
* @public
@@ -95,8 +101,11 @@ export type ServiceOutputTypes =
95101
| ApplyGuardrailCommandOutput
96102
| ConverseCommandOutput
97103
| ConverseStreamCommandOutput
104+
| GetAsyncInvokeCommandOutput
98105
| InvokeModelCommandOutput
99-
| InvokeModelWithResponseStreamCommandOutput;
106+
| InvokeModelWithResponseStreamCommandOutput
107+
| ListAsyncInvokesCommandOutput
108+
| StartAsyncInvokeCommandOutput;
100109

101110
/**
102111
* @public

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface ApplyGuardrailCommandOutput extends ApplyGuardrailResponse, __M
2929

3030
/**
3131
* <p>The action to apply a guardrail.</p>
32+
* <p>For troubleshooting some of the common errors you might encounter when using the <code>ApplyGuardrail</code> API,
33+
* see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/troubleshooting-api-error-codes.html">Troubleshooting Amazon Bedrock API Error Codes</a> in the Amazon Bedrock User Guide</p>
3234
* @example
3335
* Use a bare-bones client and the command you need to make an API call.
3436
* ```javascript

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
7979
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
8080
* },
8181
* },
82+
* video: { // VideoBlock
83+
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
84+
* source: { // VideoSource Union: only one key present
85+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
86+
* s3Location: { // S3Location
87+
* uri: "STRING_VALUE", // required
88+
* bucketOwner: "STRING_VALUE",
89+
* },
90+
* },
91+
* },
8292
* toolUse: { // ToolUseBlock
8393
* toolUseId: "STRING_VALUE", // required
8494
* name: "STRING_VALUE", // required
@@ -103,6 +113,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
103113
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
104114
* },
105115
* },
116+
* video: {
117+
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
118+
* source: {// Union: only one key present
119+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
120+
* s3Location: {
121+
* uri: "STRING_VALUE", // required
122+
* bucketOwner: "STRING_VALUE",
123+
* },
124+
* },
125+
* },
106126
* },
107127
* ],
108128
* status: "success" || "error",
@@ -174,6 +194,9 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
174194
* additionalModelResponseFieldPaths: [ // AdditionalModelResponseFieldPaths
175195
* "STRING_VALUE",
176196
* ],
197+
* requestMetadata: { // RequestMetadata
198+
* "<keys>": "STRING_VALUE",
199+
* },
177200
* performanceConfig: { // PerformanceConfiguration
178201
* latency: "standard" || "optimized",
179202
* },
@@ -200,6 +223,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
200223
* // bytes: new Uint8Array(),
201224
* // },
202225
* // },
226+
* // video: { // VideoBlock
227+
* // format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
228+
* // source: { // VideoSource Union: only one key present
229+
* // bytes: new Uint8Array(),
230+
* // s3Location: { // S3Location
231+
* // uri: "STRING_VALUE", // required
232+
* // bucketOwner: "STRING_VALUE",
233+
* // },
234+
* // },
235+
* // },
203236
* // toolUse: { // ToolUseBlock
204237
* // toolUseId: "STRING_VALUE", // required
205238
* // name: "STRING_VALUE", // required
@@ -224,6 +257,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
224257
* // bytes: new Uint8Array(),
225258
* // },
226259
* // },
260+
* // video: {
261+
* // format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
262+
* // source: {// Union: only one key present
263+
* // bytes: new Uint8Array(),
264+
* // s3Location: {
265+
* // uri: "STRING_VALUE", // required
266+
* // bucketOwner: "STRING_VALUE",
267+
* // },
268+
* // },
269+
* // },
227270
* // },
228271
* // ],
229272
* // status: "success" || "error",

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
9090
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
9191
* },
9292
* },
93+
* video: { // VideoBlock
94+
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
95+
* source: { // VideoSource Union: only one key present
96+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
97+
* s3Location: { // S3Location
98+
* uri: "STRING_VALUE", // required
99+
* bucketOwner: "STRING_VALUE",
100+
* },
101+
* },
102+
* },
93103
* toolUse: { // ToolUseBlock
94104
* toolUseId: "STRING_VALUE", // required
95105
* name: "STRING_VALUE", // required
@@ -114,6 +124,16 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
114124
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
115125
* },
116126
* },
127+
* video: {
128+
* format: "mkv" || "mov" || "mp4" || "webm" || "flv" || "mpeg" || "mpg" || "wmv" || "three_gp", // required
129+
* source: {// Union: only one key present
130+
* bytes: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
131+
* s3Location: {
132+
* uri: "STRING_VALUE", // required
133+
* bucketOwner: "STRING_VALUE",
134+
* },
135+
* },
136+
* },
117137
* },
118138
* ],
119139
* status: "success" || "error",
@@ -186,6 +206,9 @@ export interface ConverseStreamCommandOutput extends ConverseStreamResponse, __M
186206
* additionalModelResponseFieldPaths: [ // AdditionalModelResponseFieldPaths
187207
* "STRING_VALUE",
188208
* ],
209+
* requestMetadata: { // RequestMetadata
210+
* "<keys>": "STRING_VALUE",
211+
* },
189212
* performanceConfig: { // PerformanceConfiguration
190213
* latency: "standard" || "optimized",
191214
* },

0 commit comments

Comments
 (0)