Skip to main content

Amazon SageMaker

Prerequisites

Installation

npm i @winglibs/sagemaker

Usage

The library enables owners of a trained sagemaker model, to access its Endpoints from a winglang inflight code.

bring sagemaker;
bring cloud;

let sm = new sagemaker.Endpoint("my-endpoint-name", "my-inference-name");

let handler = inflight () => {
let res = sm.invoke({
inputs: "do AI stuff"
},
ContentType: "application/json"
);
log(res.Body);
};

new cloud.Function(handler);

Troubleshooting

Encountering issues? Here are some common problems and their solutions:

Error: Region is missing

Problem: When trying to invoke the sagemaker model, the region reports missing Error: Region is missing

Solution:

Add AWS_REGION to the cloud.Function environment variable:

bring sagemaker;
bring cloud;

let sm = new sagemaker.Endpoint("my-endpoint-name", "my-inference-name");

let handler = inflight () => {
let res = sm.invoke({
inputs: "do AI stuff"
},
ContentType: "application/json"
);
log(res.Body);
};

new cloud.Function(handler, env: {
"AWS_REGION":"us-west-2"
});

License

This library is licensed under the MIT License.

API Reference

Table of Contents

Endpoint (preflight class)

No description

Constructor

new(endpointName: str, inferenceComponentName: str): Endpoint

Properties

NameTypeDescription
endpointNamestrNo description

Methods

SignatureDescription
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutputNo description

SageMaker_tfaws (preflight class)

No description

Constructor

new(endpointName: str, inferenceComponentName: str): SageMaker_tfaws

Properties

NameTypeDescription
endpointNamestrNo description
inferenceComponentNamestrNo description

Methods

SignatureDescription
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutputNo description

SageMaker_sim (preflight class)

No description

Constructor

new(endpointName: str, inferenceName: str): SageMaker_sim

Properties

No properties

Methods

SignatureDescription
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutputNo description
setMockResponse(fn: inflight (Json, InvocationOptions?): InvocationOutput): voidNo description

ISageMaker (interface)

No description

Properties

No properties

Methods

SignatureDescription
inflight invoke(body: Json, InvocationOptions: InvocationOptions?): InvocationOutputNo description

InvocationOptions (struct)

No description

Properties

NameTypeDescription
Acceptstr?No description
ContentTypestr?No description
CustomAttributesstr?No description
EnableExplanationsstr?No description
InferenceComponentNamestr?No description
InferenceIdstr?No description
TargetContainerHostnamestr?No description
TargetModelstr?No description
TargetVariantstr?No description

InvocationOutput (struct)

No description

Properties

NameTypeDescription
BodystrNo description
ContentTypestr?No description
CustomAttributesstr?No description
InvokedProductionVariantstr?No description