Skip to content

Commit b07fb6e

Browse files
author
awstools
committed
feat(client-bedrock-runtime): Add model timeout exception for InvokeModelWithResponseStream API and update validator for invoke model identifier.
1 parent d233302 commit b07fb6e

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface InvokeModelCommandOutput extends InvokeModelCommandOutputType,
6060
* @public
6161
* <p>Invokes the specified Bedrock model to run inference using the input provided in the request body.
6262
* You use InvokeModel to run inference for text models, image models, and embedding models.</p>
63-
* <p>For more information about invoking models, see Using the API in the <a href="https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf">Bedrock User Guide</a>.</p>
63+
* <p>For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html">Run inference</a> in the Bedrock User Guide.</p>
6464
* <p>For example requests, see Examples (after the Errors section).</p>
6565
* @example
6666
* Use a bare-bones client and the command you need to make an API call.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export interface InvokeModelWithResponseStreamCommandOutput
5858
* @public
5959
* <p>Invoke the specified Bedrock model to run inference using the input provided.
6060
* Return the response in a stream.</p>
61-
* <p>For more information about invoking models, see Using the API in the <a href="https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf">Bedrock User Guide</a>.</p>
61+
* <p>For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html">Run inference</a> in the Bedrock User Guide.</p>
6262
* <p>For an example request and response, see Examples (after the Errors section).</p>
6363
* @example
6464
* Use a bare-bones client and the command you need to make an API call.
@@ -93,6 +93,9 @@ export interface InvokeModelWithResponseStreamCommandOutput
9393
* // throttlingException: { // ThrottlingException
9494
* // message: "STRING_VALUE",
9595
* // },
96+
* // modelTimeoutException: { // ModelTimeoutException
97+
* // message: "STRING_VALUE",
98+
* // },
9699
* // },
97100
* // contentType: "STRING_VALUE", // required
98101
* // };

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ export type ResponseStream =
331331
| ResponseStream.ChunkMember
332332
| ResponseStream.InternalServerExceptionMember
333333
| ResponseStream.ModelStreamErrorExceptionMember
334+
| ResponseStream.ModelTimeoutExceptionMember
334335
| ResponseStream.ThrottlingExceptionMember
335336
| ResponseStream.ValidationExceptionMember
336337
| ResponseStream.$UnknownMember;
@@ -349,6 +350,7 @@ export namespace ResponseStream {
349350
modelStreamErrorException?: never;
350351
validationException?: never;
351352
throttlingException?: never;
353+
modelTimeoutException?: never;
352354
$unknown?: never;
353355
}
354356

@@ -362,6 +364,7 @@ export namespace ResponseStream {
362364
modelStreamErrorException?: never;
363365
validationException?: never;
364366
throttlingException?: never;
367+
modelTimeoutException?: never;
365368
$unknown?: never;
366369
}
367370

@@ -375,6 +378,7 @@ export namespace ResponseStream {
375378
modelStreamErrorException: ModelStreamErrorException;
376379
validationException?: never;
377380
throttlingException?: never;
381+
modelTimeoutException?: never;
378382
$unknown?: never;
379383
}
380384

@@ -388,6 +392,7 @@ export namespace ResponseStream {
388392
modelStreamErrorException?: never;
389393
validationException: ValidationException;
390394
throttlingException?: never;
395+
modelTimeoutException?: never;
391396
$unknown?: never;
392397
}
393398

@@ -401,6 +406,21 @@ export namespace ResponseStream {
401406
modelStreamErrorException?: never;
402407
validationException?: never;
403408
throttlingException: ThrottlingException;
409+
modelTimeoutException?: never;
410+
$unknown?: never;
411+
}
412+
413+
/**
414+
* @public
415+
* <p>The request took too long to process. Processing time exceeded the model timeout length.</p>
416+
*/
417+
export interface ModelTimeoutExceptionMember {
418+
chunk?: never;
419+
internalServerException?: never;
420+
modelStreamErrorException?: never;
421+
validationException?: never;
422+
throttlingException?: never;
423+
modelTimeoutException: ModelTimeoutException;
404424
$unknown?: never;
405425
}
406426

@@ -413,6 +433,7 @@ export namespace ResponseStream {
413433
modelStreamErrorException?: never;
414434
validationException?: never;
415435
throttlingException?: never;
436+
modelTimeoutException?: never;
416437
$unknown: [string, any];
417438
}
418439

@@ -422,6 +443,7 @@ export namespace ResponseStream {
422443
modelStreamErrorException: (value: ModelStreamErrorException) => T;
423444
validationException: (value: ValidationException) => T;
424445
throttlingException: (value: ThrottlingException) => T;
446+
modelTimeoutException: (value: ModelTimeoutException) => T;
425447
_: (name: string, value: any) => T;
426448
}
427449

@@ -433,6 +455,7 @@ export namespace ResponseStream {
433455
return visitor.modelStreamErrorException(value.modelStreamErrorException);
434456
if (value.validationException !== undefined) return visitor.validationException(value.validationException);
435457
if (value.throttlingException !== undefined) return visitor.throttlingException(value.throttlingException);
458+
if (value.modelTimeoutException !== undefined) return visitor.modelTimeoutException(value.modelTimeoutException);
436459
return visitor._(value.$unknown[0], value.$unknown[1]);
437460
};
438461
}
@@ -497,6 +520,7 @@ export const ResponseStreamFilterSensitiveLog = (obj: ResponseStream): any => {
497520
if (obj.modelStreamErrorException !== undefined) return { modelStreamErrorException: obj.modelStreamErrorException };
498521
if (obj.validationException !== undefined) return { validationException: obj.validationException };
499522
if (obj.throttlingException !== undefined) return { throttlingException: obj.throttlingException };
523+
if (obj.modelTimeoutException !== undefined) return { modelTimeoutException: obj.modelTimeoutException };
500524
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
501525
};
502526

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ const de_ResponseStream = (
472472
throttlingException: await de_ThrottlingException_event(event["throttlingException"], context),
473473
};
474474
}
475+
if (event["modelTimeoutException"] != null) {
476+
return {
477+
modelTimeoutException: await de_ModelTimeoutException_event(event["modelTimeoutException"], context),
478+
};
479+
}
475480
return { $unknown: output };
476481
});
477482
};
@@ -495,6 +500,13 @@ const de_ModelStreamErrorException_event = async (
495500
};
496501
return de_ModelStreamErrorExceptionRes(parsedOutput, context);
497502
};
503+
const de_ModelTimeoutException_event = async (output: any, context: __SerdeContext): Promise<ModelTimeoutException> => {
504+
const parsedOutput: any = {
505+
...output,
506+
body: await parseBody(output.body, context),
507+
};
508+
return de_ModelTimeoutExceptionRes(parsedOutput, context);
509+
};
498510
const de_PayloadPart_event = async (output: any, context: __SerdeContext): Promise<PayloadPart> => {
499511
const contents: PayloadPart = {} as any;
500512
const data: any = await parseBody(output.body, context);

codegen/sdk-codegen/aws-models/bedrock-runtime.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@
771771
}
772772
],
773773
"traits": {
774-
"smithy.api#documentation": "<p>Invokes the specified Bedrock model to run inference using the input provided in the request body. \n You use InvokeModel to run inference for text models, image models, and embedding models.</p>\n <p>For more information about invoking models, see Using the API in the <a href=\"https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf\">Bedrock User Guide</a>.</p>\n <p>For example requests, see Examples (after the Errors section).</p>",
774+
"smithy.api#documentation": "<p>Invokes the specified Bedrock model to run inference using the input provided in the request body. \n You use InvokeModel to run inference for text models, image models, and embedding models.</p>\n <p>For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html\">Run inference</a> in the Bedrock User Guide.</p>\n <p>For example requests, see Examples (after the Errors section).</p>",
775775
"smithy.api#http": {
776776
"code": 200,
777777
"method": "POST",
@@ -786,7 +786,7 @@
786786
"min": 1,
787787
"max": 2048
788788
},
789-
"smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2})|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63})([:][a-z0-9-]{1,63}){0,2})|(([0-9a-zA-Z][_-]?)+)$"
789+
"smithy.api#pattern": "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63}))|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)$"
790790
}
791791
},
792792
"com.amazonaws.bedrockruntime#InvokeModelRequest": {
@@ -892,7 +892,7 @@
892892
}
893893
],
894894
"traits": {
895-
"smithy.api#documentation": "<p>Invoke the specified Bedrock model to run inference using the input provided.\n Return the response in a stream.</p>\n <p>For more information about invoking models, see Using the API in the <a href=\"https://d2eo22ngex1n9g.cloudfront.net/Documentation/BedrockUserGuide.pdf\">Bedrock User Guide</a>.</p>\n <p>For an example request and response, see Examples (after the Errors section).</p>",
895+
"smithy.api#documentation": "<p>Invoke the specified Bedrock model to run inference using the input provided.\n Return the response in a stream.</p>\n <p>For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html\">Run inference</a> in the Bedrock User Guide.</p>\n <p>For an example request and response, see Examples (after the Errors section).</p>",
896896
"smithy.api#http": {
897897
"code": 200,
898898
"method": "POST",
@@ -1104,6 +1104,9 @@
11041104
},
11051105
"throttlingException": {
11061106
"target": "com.amazonaws.bedrockruntime#ThrottlingException"
1107+
},
1108+
"modelTimeoutException": {
1109+
"target": "com.amazonaws.bedrockruntime#ModelTimeoutException"
11071110
}
11081111
},
11091112
"traits": {

0 commit comments

Comments
 (0)