Skip to content

Commit 2263b20

Browse files
author
awstools
committed
feat(client-sagemaker-runtime): This release adds a new InvokeEndpointWithResponseStream API to support streaming of model responses.
1 parent 83abe06 commit 2263b20

File tree

14 files changed

+1391
-369
lines changed

14 files changed

+1391
-369
lines changed

clients/client-sagemaker-runtime/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,11 @@ InvokeEndpointAsync
219219
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/classes/invokeendpointasynccommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointasynccommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointasynccommandoutput.html)
220220

221221
</details>
222+
<details>
223+
<summary>
224+
InvokeEndpointWithResponseStream
225+
</summary>
226+
227+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/classes/invokeendpointwithresponsestreamcommand.html) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointwithresponsestreamcommandinput.html) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sagemaker-runtime/interfaces/invokeendpointwithresponsestreamcommandoutput.html)
228+
229+
</details>

clients/client-sagemaker-runtime/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"@aws-sdk/util-user-agent-browser": "*",
3434
"@aws-sdk/util-user-agent-node": "*",
3535
"@smithy/config-resolver": "^2.0.5",
36+
"@smithy/eventstream-serde-browser": "^2.0.5",
37+
"@smithy/eventstream-serde-config-resolver": "^2.0.5",
38+
"@smithy/eventstream-serde-node": "^2.0.5",
3639
"@smithy/fetch-http-handler": "^2.0.5",
3740
"@smithy/hash-node": "^2.0.5",
3841
"@smithy/invalid-dependency": "^2.0.5",

clients/client-sagemaker-runtime/src/SageMakerRuntime.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ import {
1212
InvokeEndpointCommandInput,
1313
InvokeEndpointCommandOutput,
1414
} from "./commands/InvokeEndpointCommand";
15+
import {
16+
InvokeEndpointWithResponseStreamCommand,
17+
InvokeEndpointWithResponseStreamCommandInput,
18+
InvokeEndpointWithResponseStreamCommandOutput,
19+
} from "./commands/InvokeEndpointWithResponseStreamCommand";
1520
import { SageMakerRuntimeClient, SageMakerRuntimeClientConfig } from "./SageMakerRuntimeClient";
1621

1722
const commands = {
1823
InvokeEndpointCommand,
1924
InvokeEndpointAsyncCommand,
25+
InvokeEndpointWithResponseStreamCommand,
2026
};
2127

2228
export interface SageMakerRuntime {
@@ -50,6 +56,23 @@ export interface SageMakerRuntime {
5056
options: __HttpHandlerOptions,
5157
cb: (err: any, data?: InvokeEndpointAsyncCommandOutput) => void
5258
): void;
59+
60+
/**
61+
* @see {@link InvokeEndpointWithResponseStreamCommand}
62+
*/
63+
invokeEndpointWithResponseStream(
64+
args: InvokeEndpointWithResponseStreamCommandInput,
65+
options?: __HttpHandlerOptions
66+
): Promise<InvokeEndpointWithResponseStreamCommandOutput>;
67+
invokeEndpointWithResponseStream(
68+
args: InvokeEndpointWithResponseStreamCommandInput,
69+
cb: (err: any, data?: InvokeEndpointWithResponseStreamCommandOutput) => void
70+
): void;
71+
invokeEndpointWithResponseStream(
72+
args: InvokeEndpointWithResponseStreamCommandInput,
73+
options: __HttpHandlerOptions,
74+
cb: (err: any, data?: InvokeEndpointWithResponseStreamCommandOutput) => void
75+
): void;
5376
}
5477

5578
/**

clients/client-sagemaker-runtime/src/SageMakerRuntimeClient.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import {
2121
} from "@aws-sdk/middleware-user-agent";
2222
import { Credentials as __Credentials } from "@aws-sdk/types";
2323
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
24+
import {
25+
EventStreamSerdeInputConfig,
26+
EventStreamSerdeResolvedConfig,
27+
resolveEventStreamSerdeConfig,
28+
} from "@smithy/eventstream-serde-config-resolver";
2429
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
2530
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
2631
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
@@ -39,6 +44,7 @@ import {
3944
Decoder as __Decoder,
4045
Encoder as __Encoder,
4146
EndpointV2 as __EndpointV2,
47+
EventStreamSerdeProvider as __EventStreamSerdeProvider,
4248
Hash as __Hash,
4349
HashConstructor as __HashConstructor,
4450
HttpHandlerOptions as __HttpHandlerOptions,
@@ -55,6 +61,10 @@ import {
5561
InvokeEndpointAsyncCommandOutput,
5662
} from "./commands/InvokeEndpointAsyncCommand";
5763
import { InvokeEndpointCommandInput, InvokeEndpointCommandOutput } from "./commands/InvokeEndpointCommand";
64+
import {
65+
InvokeEndpointWithResponseStreamCommandInput,
66+
InvokeEndpointWithResponseStreamCommandOutput,
67+
} from "./commands/InvokeEndpointWithResponseStreamCommand";
5868
import {
5969
ClientInputEndpointParameters,
6070
ClientResolvedEndpointParameters,
@@ -69,12 +79,18 @@ export { __Client };
6979
/**
7080
* @public
7181
*/
72-
export type ServiceInputTypes = InvokeEndpointAsyncCommandInput | InvokeEndpointCommandInput;
82+
export type ServiceInputTypes =
83+
| InvokeEndpointAsyncCommandInput
84+
| InvokeEndpointCommandInput
85+
| InvokeEndpointWithResponseStreamCommandInput;
7386

7487
/**
7588
* @public
7689
*/
77-
export type ServiceOutputTypes = InvokeEndpointAsyncCommandOutput | InvokeEndpointCommandOutput;
90+
export type ServiceOutputTypes =
91+
| InvokeEndpointAsyncCommandOutput
92+
| InvokeEndpointCommandOutput
93+
| InvokeEndpointWithResponseStreamCommandOutput;
7894

7995
/**
8096
* @public
@@ -199,6 +215,11 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
199215
*/
200216
extensions?: RuntimeExtension[];
201217

218+
/**
219+
* The function that provides necessary utilities for generating and parsing event stream
220+
*/
221+
eventStreamSerdeProvider?: __EventStreamSerdeProvider;
222+
202223
/**
203224
* The {@link @smithy/smithy-client#DefaultsMode} that will be used to determine how certain default configuration options are resolved in the SDK.
204225
*/
@@ -216,6 +237,7 @@ export type SageMakerRuntimeClientConfigType = Partial<__SmithyConfiguration<__H
216237
HostHeaderInputConfig &
217238
AwsAuthInputConfig &
218239
UserAgentInputConfig &
240+
EventStreamSerdeInputConfig &
219241
ClientInputEndpointParameters;
220242
/**
221243
* @public
@@ -236,6 +258,7 @@ export type SageMakerRuntimeClientResolvedConfigType = __SmithyResolvedConfigura
236258
HostHeaderResolvedConfig &
237259
AwsAuthResolvedConfig &
238260
UserAgentResolvedConfig &
261+
EventStreamSerdeResolvedConfig &
239262
ClientResolvedEndpointParameters;
240263
/**
241264
* @public
@@ -268,9 +291,10 @@ export class SageMakerRuntimeClient extends __Client<
268291
const _config_5 = resolveHostHeaderConfig(_config_4);
269292
const _config_6 = resolveAwsAuthConfig(_config_5);
270293
const _config_7 = resolveUserAgentConfig(_config_6);
271-
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
272-
super(_config_8);
273-
this.config = _config_8;
294+
const _config_8 = resolveEventStreamSerdeConfig(_config_7);
295+
const _config_9 = resolveRuntimeExtensions(_config_8, configuration?.extensions || []);
296+
super(_config_9);
297+
this.config = _config_9;
274298
this.middlewareStack.use(getRetryPlugin(this.config));
275299
this.middlewareStack.use(getContentLengthPlugin(this.config));
276300
this.middlewareStack.use(getHostHeaderPlugin(this.config));

clients/client-sagemaker-runtime/src/commands/InvokeEndpointAsyncCommand.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ export interface InvokeEndpointAsyncCommandOutput extends InvokeEndpointAsyncOut
4040

4141
/**
4242
* @public
43-
* <p>After you deploy a model into production using Amazon SageMaker hosting services, your client
44-
* applications use this API to get inferences from the model hosted at the specified
45-
* endpoint in an asynchronous manner.</p>
43+
* <p>After you deploy a model into production using Amazon SageMaker hosting services,
44+
* your client applications use this API to get inferences from the model hosted at the
45+
* specified endpoint in an asynchronous manner.</p>
4646
* <p>Inference requests sent to this API are enqueued for asynchronous processing. The
4747
* processing of the inference request may or may not complete before you receive a
4848
* response from this API. The response from this API will not contain the result of the
4949
* inference request but contain information about where you can locate it.</p>
50-
* <p>Amazon SageMaker strips all <code>POST</code> headers except those supported by the API. Amazon SageMaker
51-
* might add additional headers. You should not rely on the behavior of headers outside
52-
* those enumerated in the request syntax.</p>
53-
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the
54-
* <i>Amazon S3 API Reference</i>.</p>
50+
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
51+
* additional headers. You should not rely on the behavior of headers outside those
52+
* enumerated in the request syntax. </p>
53+
* <p>Calls to <code>InvokeEndpointAsync</code> are authenticated by using Amazon Web Services Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
54+
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API Reference</i>.</p>
5555
* @example
5656
* Use a bare-bones client and the command you need to make an API call.
5757
* ```javascript

clients/client-sagemaker-runtime/src/commands/InvokeEndpointCommand.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,24 @@ export interface InvokeEndpointCommandOutput extends InvokeEndpointCommandOutput
5757

5858
/**
5959
* @public
60-
* <p>After you deploy a model into production using Amazon SageMaker hosting services, your
61-
* client applications use this API to get inferences from the model hosted at the
60+
* <p>After you deploy a model into production using Amazon SageMaker hosting services,
61+
* your client applications use this API to get inferences from the model hosted at the
6262
* specified endpoint. </p>
6363
* <p>For an overview of Amazon SageMaker, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html">How It Works</a>. </p>
6464
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
65-
* additional headers. You should not rely on the behavior of headers outside those
66-
* enumerated in the request syntax. </p>
65+
* additional headers. You should not rely on the behavior of headers outside those
66+
* enumerated in the request syntax. </p>
6767
* <p>Calls to <code>InvokeEndpoint</code> are authenticated by using Amazon Web Services
6868
* Signature Version 4. For information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating
69-
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API
70-
* Reference</i>.</p>
69+
* Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon S3 API Reference</i>.</p>
7170
* <p>A customer's model containers must respond to requests within 60 seconds. The model
7271
* itself can have a maximum processing time of 60 seconds before responding to
7372
* invocations. If your model is going to take 50-60 seconds of processing time, the SDK
7473
* socket timeout should be set to be 70 seconds.</p>
7574
* <note>
7675
* <p>Endpoints are scoped to an individual account, and are not public. The URL does
77-
* not contain the account ID, but Amazon SageMaker determines the account ID from the
78-
* authentication token that is supplied by the caller.</p>
76+
* not contain the account ID, but Amazon SageMaker determines the account ID from
77+
* the authentication token that is supplied by the caller.</p>
7978
* </note>
8079
* @example
8180
* Use a bare-bones client and the command you need to make an API call.

0 commit comments

Comments
 (0)