From b07fb6e025f3a33306d519c044119c937b902b1a Mon Sep 17 00:00:00 2001 From: awstools Date: Mon, 2 Oct 2023 18:20:26 +0000 Subject: [PATCH] feat(client-bedrock-runtime): Add model timeout exception for InvokeModelWithResponseStream API and update validator for invoke model identifier. --- .../src/commands/InvokeModelCommand.ts | 2 +- .../InvokeModelWithResponseStreamCommand.ts | 5 +++- .../src/models/models_0.ts | 24 +++++++++++++++++++ .../src/protocols/Aws_restJson1.ts | 12 ++++++++++ .../aws-models/bedrock-runtime.json | 9 ++++--- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/clients/client-bedrock-runtime/src/commands/InvokeModelCommand.ts b/clients/client-bedrock-runtime/src/commands/InvokeModelCommand.ts index 211d4597d68cb..d55109a379ee9 100644 --- a/clients/client-bedrock-runtime/src/commands/InvokeModelCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/InvokeModelCommand.ts @@ -60,7 +60,7 @@ export interface InvokeModelCommandOutput extends InvokeModelCommandOutputType, * @public *

Invokes the specified Bedrock model to run inference using the input provided in the request body. * You use InvokeModel to run inference for text models, image models, and embedding models.

- *

For more information about invoking models, see Using the API in the Bedrock User Guide.

+ *

For more information, see Run inference in the Bedrock User Guide.

*

For example requests, see Examples (after the Errors section).

* @example * Use a bare-bones client and the command you need to make an API call. diff --git a/clients/client-bedrock-runtime/src/commands/InvokeModelWithResponseStreamCommand.ts b/clients/client-bedrock-runtime/src/commands/InvokeModelWithResponseStreamCommand.ts index 4cf68e3cdff6a..51517f00f5c30 100644 --- a/clients/client-bedrock-runtime/src/commands/InvokeModelWithResponseStreamCommand.ts +++ b/clients/client-bedrock-runtime/src/commands/InvokeModelWithResponseStreamCommand.ts @@ -58,7 +58,7 @@ export interface InvokeModelWithResponseStreamCommandOutput * @public *

Invoke the specified Bedrock model to run inference using the input provided. * Return the response in a stream.

- *

For more information about invoking models, see Using the API in the Bedrock User Guide.

+ *

For more information, see Run inference in the Bedrock User Guide.

*

For an example request and response, see Examples (after the Errors section).

* @example * Use a bare-bones client and the command you need to make an API call. @@ -93,6 +93,9 @@ export interface InvokeModelWithResponseStreamCommandOutput * // throttlingException: { // ThrottlingException * // message: "STRING_VALUE", * // }, + * // modelTimeoutException: { // ModelTimeoutException + * // message: "STRING_VALUE", + * // }, * // }, * // contentType: "STRING_VALUE", // required * // }; diff --git a/clients/client-bedrock-runtime/src/models/models_0.ts b/clients/client-bedrock-runtime/src/models/models_0.ts index 2196b6942119a..19a28a5c89649 100644 --- a/clients/client-bedrock-runtime/src/models/models_0.ts +++ b/clients/client-bedrock-runtime/src/models/models_0.ts @@ -331,6 +331,7 @@ export type ResponseStream = | ResponseStream.ChunkMember | ResponseStream.InternalServerExceptionMember | ResponseStream.ModelStreamErrorExceptionMember + | ResponseStream.ModelTimeoutExceptionMember | ResponseStream.ThrottlingExceptionMember | ResponseStream.ValidationExceptionMember | ResponseStream.$UnknownMember; @@ -349,6 +350,7 @@ export namespace ResponseStream { modelStreamErrorException?: never; validationException?: never; throttlingException?: never; + modelTimeoutException?: never; $unknown?: never; } @@ -362,6 +364,7 @@ export namespace ResponseStream { modelStreamErrorException?: never; validationException?: never; throttlingException?: never; + modelTimeoutException?: never; $unknown?: never; } @@ -375,6 +378,7 @@ export namespace ResponseStream { modelStreamErrorException: ModelStreamErrorException; validationException?: never; throttlingException?: never; + modelTimeoutException?: never; $unknown?: never; } @@ -388,6 +392,7 @@ export namespace ResponseStream { modelStreamErrorException?: never; validationException: ValidationException; throttlingException?: never; + modelTimeoutException?: never; $unknown?: never; } @@ -401,6 +406,21 @@ export namespace ResponseStream { modelStreamErrorException?: never; validationException?: never; throttlingException: ThrottlingException; + modelTimeoutException?: never; + $unknown?: never; + } + + /** + * @public + *

The request took too long to process. Processing time exceeded the model timeout length.

+ */ + export interface ModelTimeoutExceptionMember { + chunk?: never; + internalServerException?: never; + modelStreamErrorException?: never; + validationException?: never; + throttlingException?: never; + modelTimeoutException: ModelTimeoutException; $unknown?: never; } @@ -413,6 +433,7 @@ export namespace ResponseStream { modelStreamErrorException?: never; validationException?: never; throttlingException?: never; + modelTimeoutException?: never; $unknown: [string, any]; } @@ -422,6 +443,7 @@ export namespace ResponseStream { modelStreamErrorException: (value: ModelStreamErrorException) => T; validationException: (value: ValidationException) => T; throttlingException: (value: ThrottlingException) => T; + modelTimeoutException: (value: ModelTimeoutException) => T; _: (name: string, value: any) => T; } @@ -433,6 +455,7 @@ export namespace ResponseStream { return visitor.modelStreamErrorException(value.modelStreamErrorException); if (value.validationException !== undefined) return visitor.validationException(value.validationException); if (value.throttlingException !== undefined) return visitor.throttlingException(value.throttlingException); + if (value.modelTimeoutException !== undefined) return visitor.modelTimeoutException(value.modelTimeoutException); return visitor._(value.$unknown[0], value.$unknown[1]); }; } @@ -497,6 +520,7 @@ export const ResponseStreamFilterSensitiveLog = (obj: ResponseStream): any => { if (obj.modelStreamErrorException !== undefined) return { modelStreamErrorException: obj.modelStreamErrorException }; if (obj.validationException !== undefined) return { validationException: obj.validationException }; if (obj.throttlingException !== undefined) return { throttlingException: obj.throttlingException }; + if (obj.modelTimeoutException !== undefined) return { modelTimeoutException: obj.modelTimeoutException }; if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" }; }; diff --git a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts index 7f6332d488371..98eff12831adf 100644 --- a/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-bedrock-runtime/src/protocols/Aws_restJson1.ts @@ -472,6 +472,11 @@ const de_ResponseStream = ( throttlingException: await de_ThrottlingException_event(event["throttlingException"], context), }; } + if (event["modelTimeoutException"] != null) { + return { + modelTimeoutException: await de_ModelTimeoutException_event(event["modelTimeoutException"], context), + }; + } return { $unknown: output }; }); }; @@ -495,6 +500,13 @@ const de_ModelStreamErrorException_event = async ( }; return de_ModelStreamErrorExceptionRes(parsedOutput, context); }; +const de_ModelTimeoutException_event = async (output: any, context: __SerdeContext): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + return de_ModelTimeoutExceptionRes(parsedOutput, context); +}; const de_PayloadPart_event = async (output: any, context: __SerdeContext): Promise => { const contents: PayloadPart = {} as any; const data: any = await parseBody(output.body, context); diff --git a/codegen/sdk-codegen/aws-models/bedrock-runtime.json b/codegen/sdk-codegen/aws-models/bedrock-runtime.json index fc51cf492928e..710268619acf6 100644 --- a/codegen/sdk-codegen/aws-models/bedrock-runtime.json +++ b/codegen/sdk-codegen/aws-models/bedrock-runtime.json @@ -771,7 +771,7 @@ } ], "traits": { - "smithy.api#documentation": "

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.

\n

For more information about invoking models, see Using the API in the Bedrock User Guide.

\n

For example requests, see Examples (after the Errors section).

", + "smithy.api#documentation": "

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.

\n

For more information, see Run inference in the Bedrock User Guide.

\n

For example requests, see Examples (after the Errors section).

", "smithy.api#http": { "code": 200, "method": "POST", @@ -786,7 +786,7 @@ "min": 1, "max": 2048 }, - "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][_-]?)+)$" + "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][_-]?)+)$" } }, "com.amazonaws.bedrockruntime#InvokeModelRequest": { @@ -892,7 +892,7 @@ } ], "traits": { - "smithy.api#documentation": "

Invoke the specified Bedrock model to run inference using the input provided.\n Return the response in a stream.

\n

For more information about invoking models, see Using the API in the Bedrock User Guide.

\n

For an example request and response, see Examples (after the Errors section).

", + "smithy.api#documentation": "

Invoke the specified Bedrock model to run inference using the input provided.\n Return the response in a stream.

\n

For more information, see Run inference in the Bedrock User Guide.

\n

For an example request and response, see Examples (after the Errors section).

", "smithy.api#http": { "code": 200, "method": "POST", @@ -1104,6 +1104,9 @@ }, "throttlingException": { "target": "com.amazonaws.bedrockruntime#ThrottlingException" + }, + "modelTimeoutException": { + "target": "com.amazonaws.bedrockruntime#ModelTimeoutException" } }, "traits": {