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
- Classes
- Interfaces
- Structs
Endpoint (preflight class)
No description
Constructor
new(endpointName: str, inferenceComponentName: str): Endpoint
Properties
Name | Type | Description |
---|---|---|
endpointName | str | No description |
Methods
Signature | Description |
---|---|
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutput | No description |
SageMaker_tfaws (preflight class)
No description
Constructor
new(endpointName: str, inferenceComponentName: str): SageMaker_tfaws
Properties
Name | Type | Description |
---|---|---|
endpointName | str | No description |
inferenceComponentName | str | No description |
Methods
Signature | Description |
---|---|
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutput | No description |
SageMaker_sim (preflight class)
No description
Constructor
new(endpointName: str, inferenceName: str): SageMaker_sim
Properties
No properties
Methods
Signature | Description |
---|---|
inflight invoke(body: Json, options: InvocationOptions?): InvocationOutput | No description |
setMockResponse(fn: inflight (Json, InvocationOptions?): InvocationOutput): void | No description |
ISageMaker (interface)
No description
Properties
No properties
Methods
Signature | Description |
---|---|
inflight invoke(body: Json, InvocationOptions: InvocationOptions?): InvocationOutput | No description |
InvocationOptions (struct)
No description
Properties
Name | Type | Description |
---|---|---|
Accept | str? | No description |
ContentType | str? | No description |
CustomAttributes | str? | No description |
EnableExplanations | str? | No description |
InferenceComponentName | str? | No description |
InferenceId | str? | No description |
TargetContainerHostname | str? | No description |
TargetModel | str? | No description |
TargetVariant | str? | No description |
InvocationOutput (struct)
No description
Properties
Name | Type | Description |
---|---|---|
Body | str | No description |
ContentType | str? | No description |
CustomAttributes | str? | No description |
InvokedProductionVariant | str? | No description |