Skip to content

Commit

Permalink
feat(client-sagemaker-runtime): This release adds InferenceComponentN…
Browse files Browse the repository at this point in the history
…ame to InvokeEndpoint and InvokeEndpointWithResponseStream APIs to get inferences from the deployed InferenceComponents.
  • Loading branch information
awstools committed Nov 29, 2023
1 parent a8ae1e9 commit 0e02d0a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface InvokeEndpointCommandOutput extends InvokeEndpointCommandOutput
* TargetContainerHostname: "STRING_VALUE",
* InferenceId: "STRING_VALUE",
* EnableExplanations: "STRING_VALUE",
* InferenceComponentName: "STRING_VALUE",
* };
* const command = new InvokeEndpointCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export interface InvokeEndpointWithResponseStreamCommandOutput
* <p>For information about how to process the streaming response, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-test-endpoints.html">Invoke real-time endpoints</a>.</p>
* </li>
* </ul>
* <p>Before you can use this operation, your IAM permissions must allow the
* <code>sagemaker:InvokeEndpoint</code> action. For more information about Amazon SageMaker actions for IAM policies, see <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsagemaker.html">Actions, resources, and condition keys for Amazon SageMaker</a> in the <i>IAM Service Authorization
* Reference</i>.</p>
* <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add
* additional headers. You should not rely on the behavior of headers outside those
* enumerated in the request syntax. </p>
Expand All @@ -93,6 +96,7 @@ export interface InvokeEndpointWithResponseStreamCommandOutput
* TargetVariant: "STRING_VALUE",
* TargetContainerHostname: "STRING_VALUE",
* InferenceId: "STRING_VALUE",
* InferenceComponentName: "STRING_VALUE",
* };
* const command = new InvokeEndpointWithResponseStreamCommand(input);
* const response = await client.send(command);
Expand Down
14 changes: 14 additions & 0 deletions clients/client-sagemaker-runtime/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ export interface InvokeEndpointInput {
* </p>
*/
EnableExplanations?: string;

/**
* @public
* <p>If the endpoint hosts one or more inference components, this parameter specifies the
* name of inference component to invoke.</p>
*/
InferenceComponentName?: string;
}

/**
Expand Down Expand Up @@ -494,6 +501,13 @@ export interface InvokeEndpointWithResponseStreamInput {
* <p>An identifier that you assign to your request.</p>
*/
InferenceId?: string;

/**
* @public
* <p>If the endpoint hosts one or more inference components, this parameter specifies the
* name of inference component to invoke for a streaming response.</p>
*/
InferenceComponentName?: string;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const se_InvokeEndpointCommand = async (
"x-amzn-sagemaker-target-container-hostname": input.TargetContainerHostname!,
"x-amzn-sagemaker-inference-id": input.InferenceId!,
"x-amzn-sagemaker-enable-explanations": input.EnableExplanations!,
"x-amzn-sagemaker-inference-component": input.InferenceComponentName!,
});
let resolvedPath =
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/endpoints/{EndpointName}/invocations";
Expand Down Expand Up @@ -147,6 +148,7 @@ export const se_InvokeEndpointWithResponseStreamCommand = async (
"x-amzn-sagemaker-target-variant": input.TargetVariant!,
"x-amzn-sagemaker-target-container-hostname": input.TargetContainerHostname!,
"x-amzn-sagemaker-inference-id": input.InferenceId!,
"x-amzn-sagemaker-inference-component": input.InferenceComponentName!,
});
let resolvedPath =
`${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
Expand Down
26 changes: 25 additions & 1 deletion codegen/sdk-codegen/aws-models/sagemaker-runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,16 @@
"smithy.api#pattern": "^\\p{ASCII}*$"
}
},
"com.amazonaws.sagemakerruntime#InferenceComponentHeader": {
"type": "string",
"traits": {
"smithy.api#length": {
"min": 0,
"max": 63
},
"smithy.api#pattern": "^[a-zA-Z0-9]([\\-a-zA-Z0-9]*[a-zA-Z0-9])?$"
}
},
"com.amazonaws.sagemakerruntime#InferenceId": {
"type": "string",
"traits": {
Expand Down Expand Up @@ -1432,6 +1442,13 @@
"smithy.api#documentation": "<p>An optional JMESPath expression used to override the <code>EnableExplanations</code>\n parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html#clarify-online-explainability-create-endpoint-enable\">EnableExplanations</a> section in the developer guide for more information.\n </p>",
"smithy.api#httpHeader": "X-Amzn-SageMaker-Enable-Explanations"
}
},
"InferenceComponentName": {
"target": "com.amazonaws.sagemakerruntime#InferenceComponentHeader",
"traits": {
"smithy.api#documentation": "<p>If the endpoint hosts one or more inference components, this parameter specifies the\n name of inference component to invoke.</p>",
"smithy.api#httpHeader": "X-Amzn-SageMaker-Inference-Component"
}
}
},
"traits": {
Expand Down Expand Up @@ -1505,7 +1522,7 @@
}
],
"traits": {
"smithy.api#documentation": "<p>Invokes a model at the specified endpoint to return the inference response as a\n stream. The inference stream provides the response payload incrementally as a series of\n parts. Before you can get an inference stream, you must have access to a model that's\n deployed using Amazon SageMaker hosting services, and the container for that model\n must support inference streaming.</p>\n <p>For more information that can help you use this API, see the following sections in the\n <i>Amazon SageMaker Developer Guide</i>:</p>\n <ul>\n <li>\n <p>For information about how to add streaming support to a model, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-code-how-containe-serves-requests\">How Containers Serve Requests</a>.</p>\n </li>\n <li>\n <p>For information about how to process the streaming response, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-test-endpoints.html\">Invoke real-time endpoints</a>.</p>\n </li>\n </ul>\n <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add\n additional headers. You should not rely on the behavior of headers outside those\n enumerated in the request syntax. </p>\n <p>Calls to <code>InvokeEndpointWithResponseStream</code> are authenticated by using\n 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\n <i>Amazon S3 API Reference</i>.</p>",
"smithy.api#documentation": "<p>Invokes a model at the specified endpoint to return the inference response as a\n stream. The inference stream provides the response payload incrementally as a series of\n parts. Before you can get an inference stream, you must have access to a model that's\n deployed using Amazon SageMaker hosting services, and the container for that model\n must support inference streaming.</p>\n <p>For more information that can help you use this API, see the following sections in the\n <i>Amazon SageMaker Developer Guide</i>:</p>\n <ul>\n <li>\n <p>For information about how to add streaming support to a model, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-code-how-containe-serves-requests\">How Containers Serve Requests</a>.</p>\n </li>\n <li>\n <p>For information about how to process the streaming response, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-test-endpoints.html\">Invoke real-time endpoints</a>.</p>\n </li>\n </ul>\n <p>Before you can use this operation, your IAM permissions must allow the\n <code>sagemaker:InvokeEndpoint</code> action. For more information about Amazon SageMaker actions for IAM policies, see <a href=\"https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonsagemaker.html\">Actions, resources, and condition keys for Amazon SageMaker</a> in the <i>IAM Service Authorization\n Reference</i>.</p>\n <p>Amazon SageMaker strips all POST headers except those supported by the API. Amazon SageMaker might add\n additional headers. You should not rely on the behavior of headers outside those\n enumerated in the request syntax. </p>\n <p>Calls to <code>InvokeEndpointWithResponseStream</code> are authenticated by using\n 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\n <i>Amazon S3 API Reference</i>.</p>",
"smithy.api#http": {
"method": "POST",
"uri": "/endpoints/{EndpointName}/invocations-response-stream",
Expand Down Expand Up @@ -1574,6 +1591,13 @@
"smithy.api#documentation": "<p>An identifier that you assign to your request.</p>",
"smithy.api#httpHeader": "X-Amzn-SageMaker-Inference-Id"
}
},
"InferenceComponentName": {
"target": "com.amazonaws.sagemakerruntime#InferenceComponentHeader",
"traits": {
"smithy.api#documentation": "<p>If the endpoint hosts one or more inference components, this parameter specifies the\n name of inference component to invoke for a streaming response.</p>",
"smithy.api#httpHeader": "X-Amzn-SageMaker-Inference-Component"
}
}
},
"traits": {
Expand Down

0 comments on commit 0e02d0a

Please sign in to comment.