Skip to content

Commit 8d5c63a

Browse files
author
awstools
committedJan 22, 2025
feat(client-bedrock-agent-runtime): Adds multi-turn input support for an Agent node in an Amazon Bedrock Flow
1 parent e504341 commit 8d5c63a

File tree

4 files changed

+281
-10
lines changed

4 files changed

+281
-10
lines changed
 

‎clients/client-bedrock-agent-runtime/src/commands/InvokeFlowCommand.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataB
5353
* inputs: [ // FlowInputs // required
5454
* { // FlowInput
5555
* nodeName: "STRING_VALUE", // required
56-
* nodeOutputName: "STRING_VALUE", // required
56+
* nodeOutputName: "STRING_VALUE",
5757
* content: { // FlowInputContent Union: only one key present
5858
* document: "DOCUMENT_VALUE",
5959
* },
60+
* nodeInputName: "STRING_VALUE",
6061
* },
6162
* ],
6263
* enableTrace: true || false,
@@ -65,6 +66,7 @@ export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataB
6566
* latency: "standard" || "optimized",
6667
* },
6768
* },
69+
* executionId: "STRING_VALUE",
6870
* };
6971
* const command = new InvokeFlowCommand(input);
7072
* const response = await client.send(command);
@@ -78,7 +80,7 @@ export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataB
7880
* // },
7981
* // },
8082
* // flowCompletionEvent: { // FlowCompletionEvent
81-
* // completionReason: "SUCCESS", // required
83+
* // completionReason: "SUCCESS" || "INPUT_REQUIRED", // required
8284
* // },
8385
* // flowTraceEvent: { // FlowTraceEvent
8486
* // trace: { // FlowTrace Union: only one key present
@@ -146,7 +148,15 @@ export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataB
146148
* // message: "STRING_VALUE",
147149
* // resourceName: "STRING_VALUE",
148150
* // },
151+
* // flowMultiTurnInputRequestEvent: { // FlowMultiTurnInputRequestEvent
152+
* // nodeName: "STRING_VALUE", // required
153+
* // nodeType: "FlowInputNode" || "FlowOutputNode" || "LambdaFunctionNode" || "KnowledgeBaseNode" || "PromptNode" || "ConditionNode" || "LexNode", // required
154+
* // content: { // FlowMultiTurnInputContent Union: only one key present
155+
* // document: "DOCUMENT_VALUE",
156+
* // },
157+
* // },
149158
* // },
159+
* // executionId: "STRING_VALUE",
150160
* // };
151161
*
152162
* ```

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

+136-6
Original file line numberDiff line numberDiff line change
@@ -1325,13 +1325,19 @@ export interface FlowInput {
13251325
* <p>The name of the output from the flow input node that begins the prompt flow.</p>
13261326
* @public
13271327
*/
1328-
nodeOutputName: string | undefined;
1328+
nodeOutputName?: string | undefined;
13291329

13301330
/**
13311331
* <p>Contains information about an input into the prompt flow.</p>
13321332
* @public
13331333
*/
13341334
content: FlowInputContent | undefined;
1335+
1336+
/**
1337+
* <p>The name of the input from the flow input node.</p>
1338+
* @public
1339+
*/
1340+
nodeInputName?: string | undefined;
13351341
}
13361342

13371343
/**
@@ -1405,13 +1411,20 @@ export interface InvokeFlowRequest {
14051411
* @public
14061412
*/
14071413
modelPerformanceConfiguration?: ModelPerformanceConfiguration | undefined;
1414+
1415+
/**
1416+
* <p>The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you. </p>
1417+
* @public
1418+
*/
1419+
executionId?: string | undefined;
14081420
}
14091421

14101422
/**
14111423
* @public
14121424
* @enum
14131425
*/
14141426
export const FlowCompletionReason = {
1427+
INPUT_REQUIRED: "INPUT_REQUIRED",
14151428
SUCCESS: "SUCCESS",
14161429
} as const;
14171430

@@ -1433,17 +1446,19 @@ export interface FlowCompletionEvent {
14331446
}
14341447

14351448
/**
1436-
* <p>Contains information about the content in an output from prompt flow invocation.</p>
1449+
* <p>The content structure containing input information for multi-turn flow interactions.</p>
14371450
* @public
14381451
*/
1439-
export type FlowOutputContent = FlowOutputContent.DocumentMember | FlowOutputContent.$UnknownMember;
1452+
export type FlowMultiTurnInputContent =
1453+
| FlowMultiTurnInputContent.DocumentMember
1454+
| FlowMultiTurnInputContent.$UnknownMember;
14401455

14411456
/**
14421457
* @public
14431458
*/
1444-
export namespace FlowOutputContent {
1459+
export namespace FlowMultiTurnInputContent {
14451460
/**
1446-
* <p>The content in the output.</p>
1461+
* <p>The requested additional input to send back to the multi-turn flow node.</p>
14471462
* @public
14481463
*/
14491464
export interface DocumentMember {
@@ -1464,7 +1479,7 @@ export namespace FlowOutputContent {
14641479
_: (name: string, value: any) => T;
14651480
}
14661481

1467-
export const visit = <T>(value: FlowOutputContent, visitor: Visitor<T>): T => {
1482+
export const visit = <T>(value: FlowMultiTurnInputContent, visitor: Visitor<T>): T => {
14681483
if (value.document !== undefined) return visitor.document(value.document);
14691484
return visitor._(value.$unknown[0], value.$unknown[1]);
14701485
};
@@ -1489,6 +1504,68 @@ export const NodeType = {
14891504
*/
14901505
export type NodeType = (typeof NodeType)[keyof typeof NodeType];
14911506

1507+
/**
1508+
* <p>Response object from the flow multi-turn node requesting additional information.</p>
1509+
* @public
1510+
*/
1511+
export interface FlowMultiTurnInputRequestEvent {
1512+
/**
1513+
* <p>The name of the node in the flow that is requesting the input.</p>
1514+
* @public
1515+
*/
1516+
nodeName: string | undefined;
1517+
1518+
/**
1519+
* <p>The type of the node in the flow that is requesting the input.</p>
1520+
* @public
1521+
*/
1522+
nodeType: NodeType | undefined;
1523+
1524+
/**
1525+
* <p>The content payload containing the input request details for the multi-turn interaction.</p>
1526+
* @public
1527+
*/
1528+
content: FlowMultiTurnInputContent | undefined;
1529+
}
1530+
1531+
/**
1532+
* <p>Contains information about the content in an output from prompt flow invocation.</p>
1533+
* @public
1534+
*/
1535+
export type FlowOutputContent = FlowOutputContent.DocumentMember | FlowOutputContent.$UnknownMember;
1536+
1537+
/**
1538+
* @public
1539+
*/
1540+
export namespace FlowOutputContent {
1541+
/**
1542+
* <p>The content in the output.</p>
1543+
* @public
1544+
*/
1545+
export interface DocumentMember {
1546+
document: __DocumentType;
1547+
$unknown?: never;
1548+
}
1549+
1550+
/**
1551+
* @public
1552+
*/
1553+
export interface $UnknownMember {
1554+
document?: never;
1555+
$unknown: [string, any];
1556+
}
1557+
1558+
export interface Visitor<T> {
1559+
document: (value: __DocumentType) => T;
1560+
_: (name: string, value: any) => T;
1561+
}
1562+
1563+
export const visit = <T>(value: FlowOutputContent, visitor: Visitor<T>): T => {
1564+
if (value.document !== undefined) return visitor.document(value.document);
1565+
return visitor._(value.$unknown[0], value.$unknown[1]);
1566+
};
1567+
}
1568+
14921569
/**
14931570
* <p>Contains information about an output from prompt flow invoction.</p>
14941571
* @public
@@ -1888,6 +1965,7 @@ export type FlowResponseStream =
18881965
| FlowResponseStream.ConflictExceptionMember
18891966
| FlowResponseStream.DependencyFailedExceptionMember
18901967
| FlowResponseStream.FlowCompletionEventMember
1968+
| FlowResponseStream.FlowMultiTurnInputRequestEventMember
18911969
| FlowResponseStream.FlowOutputEventMember
18921970
| FlowResponseStream.FlowTraceEventMember
18931971
| FlowResponseStream.InternalServerExceptionMember
@@ -1918,6 +1996,7 @@ export namespace FlowResponseStream {
19181996
conflictException?: never;
19191997
dependencyFailedException?: never;
19201998
badGatewayException?: never;
1999+
flowMultiTurnInputRequestEvent?: never;
19212000
$unknown?: never;
19222001
}
19232002

@@ -1938,6 +2017,7 @@ export namespace FlowResponseStream {
19382017
conflictException?: never;
19392018
dependencyFailedException?: never;
19402019
badGatewayException?: never;
2020+
flowMultiTurnInputRequestEvent?: never;
19412021
$unknown?: never;
19422022
}
19432023

@@ -1958,6 +2038,7 @@ export namespace FlowResponseStream {
19582038
conflictException?: never;
19592039
dependencyFailedException?: never;
19602040
badGatewayException?: never;
2041+
flowMultiTurnInputRequestEvent?: never;
19612042
$unknown?: never;
19622043
}
19632044

@@ -1978,6 +2059,7 @@ export namespace FlowResponseStream {
19782059
conflictException?: never;
19792060
dependencyFailedException?: never;
19802061
badGatewayException?: never;
2062+
flowMultiTurnInputRequestEvent?: never;
19812063
$unknown?: never;
19822064
}
19832065

@@ -1998,6 +2080,7 @@ export namespace FlowResponseStream {
19982080
conflictException?: never;
19992081
dependencyFailedException?: never;
20002082
badGatewayException?: never;
2083+
flowMultiTurnInputRequestEvent?: never;
20012084
$unknown?: never;
20022085
}
20032086

@@ -2018,6 +2101,7 @@ export namespace FlowResponseStream {
20182101
conflictException?: never;
20192102
dependencyFailedException?: never;
20202103
badGatewayException?: never;
2104+
flowMultiTurnInputRequestEvent?: never;
20212105
$unknown?: never;
20222106
}
20232107

@@ -2038,6 +2122,7 @@ export namespace FlowResponseStream {
20382122
conflictException?: never;
20392123
dependencyFailedException?: never;
20402124
badGatewayException?: never;
2125+
flowMultiTurnInputRequestEvent?: never;
20412126
$unknown?: never;
20422127
}
20432128

@@ -2058,6 +2143,7 @@ export namespace FlowResponseStream {
20582143
conflictException?: never;
20592144
dependencyFailedException?: never;
20602145
badGatewayException?: never;
2146+
flowMultiTurnInputRequestEvent?: never;
20612147
$unknown?: never;
20622148
}
20632149

@@ -2078,6 +2164,7 @@ export namespace FlowResponseStream {
20782164
conflictException?: never;
20792165
dependencyFailedException?: never;
20802166
badGatewayException?: never;
2167+
flowMultiTurnInputRequestEvent?: never;
20812168
$unknown?: never;
20822169
}
20832170

@@ -2098,6 +2185,7 @@ export namespace FlowResponseStream {
20982185
conflictException: ConflictException;
20992186
dependencyFailedException?: never;
21002187
badGatewayException?: never;
2188+
flowMultiTurnInputRequestEvent?: never;
21012189
$unknown?: never;
21022190
}
21032191

@@ -2118,6 +2206,7 @@ export namespace FlowResponseStream {
21182206
conflictException?: never;
21192207
dependencyFailedException: DependencyFailedException;
21202208
badGatewayException?: never;
2209+
flowMultiTurnInputRequestEvent?: never;
21212210
$unknown?: never;
21222211
}
21232212

@@ -2138,6 +2227,28 @@ export namespace FlowResponseStream {
21382227
conflictException?: never;
21392228
dependencyFailedException?: never;
21402229
badGatewayException: BadGatewayException;
2230+
flowMultiTurnInputRequestEvent?: never;
2231+
$unknown?: never;
2232+
}
2233+
2234+
/**
2235+
* <p>The event stream containing the multi-turn input request information from the flow.</p>
2236+
* @public
2237+
*/
2238+
export interface FlowMultiTurnInputRequestEventMember {
2239+
flowOutputEvent?: never;
2240+
flowCompletionEvent?: never;
2241+
flowTraceEvent?: never;
2242+
internalServerException?: never;
2243+
validationException?: never;
2244+
resourceNotFoundException?: never;
2245+
serviceQuotaExceededException?: never;
2246+
throttlingException?: never;
2247+
accessDeniedException?: never;
2248+
conflictException?: never;
2249+
dependencyFailedException?: never;
2250+
badGatewayException?: never;
2251+
flowMultiTurnInputRequestEvent: FlowMultiTurnInputRequestEvent;
21412252
$unknown?: never;
21422253
}
21432254

@@ -2157,6 +2268,7 @@ export namespace FlowResponseStream {
21572268
conflictException?: never;
21582269
dependencyFailedException?: never;
21592270
badGatewayException?: never;
2271+
flowMultiTurnInputRequestEvent?: never;
21602272
$unknown: [string, any];
21612273
}
21622274

@@ -2173,6 +2285,7 @@ export namespace FlowResponseStream {
21732285
conflictException: (value: ConflictException) => T;
21742286
dependencyFailedException: (value: DependencyFailedException) => T;
21752287
badGatewayException: (value: BadGatewayException) => T;
2288+
flowMultiTurnInputRequestEvent: (value: FlowMultiTurnInputRequestEvent) => T;
21762289
_: (name: string, value: any) => T;
21772290
}
21782291

@@ -2193,6 +2306,8 @@ export namespace FlowResponseStream {
21932306
if (value.dependencyFailedException !== undefined)
21942307
return visitor.dependencyFailedException(value.dependencyFailedException);
21952308
if (value.badGatewayException !== undefined) return visitor.badGatewayException(value.badGatewayException);
2309+
if (value.flowMultiTurnInputRequestEvent !== undefined)
2310+
return visitor.flowMultiTurnInputRequestEvent(value.flowMultiTurnInputRequestEvent);
21962311
return visitor._(value.$unknown[0], value.$unknown[1]);
21972312
};
21982313
}
@@ -2206,6 +2321,12 @@ export interface InvokeFlowResponse {
22062321
* @public
22072322
*/
22082323
responseStream: AsyncIterable<FlowResponseStream> | undefined;
2324+
2325+
/**
2326+
* <p>The unique identifier for the current flow execution.</p>
2327+
* @public
2328+
*/
2329+
executionId?: string | undefined;
22092330
}
22102331

22112332
/**
@@ -9045,6 +9166,14 @@ export const FlowCompletionEventFilterSensitiveLog = (obj: FlowCompletionEvent):
90459166
...obj,
90469167
});
90479168

9169+
/**
9170+
* @internal
9171+
*/
9172+
export const FlowMultiTurnInputRequestEventFilterSensitiveLog = (obj: FlowMultiTurnInputRequestEvent): any => ({
9173+
...obj,
9174+
...(obj.content && { content: obj.content }),
9175+
});
9176+
90489177
/**
90499178
* @internal
90509179
*/
@@ -9143,6 +9272,7 @@ export const FlowResponseStreamFilterSensitiveLog = (obj: FlowResponseStream): a
91439272
if (obj.conflictException !== undefined) return { conflictException: obj.conflictException };
91449273
if (obj.dependencyFailedException !== undefined) return { dependencyFailedException: obj.dependencyFailedException };
91459274
if (obj.badGatewayException !== undefined) return { badGatewayException: obj.badGatewayException };
9275+
if (obj.flowMultiTurnInputRequestEvent !== undefined) return { flowMultiTurnInputRequestEvent: SENSITIVE_STRING };
91469276
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
91479277
};
91489278

0 commit comments

Comments
 (0)
Please sign in to comment.