- Notifications
You must be signed in to change notification settings - Fork3
The official JavaScript SDK for the Modzy Machine Learning Operations (MLOps) Platform.
License
modzy/sdk-javascript
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Intall Modzy's JavaScript SDK with NPM
npm install @modzy/modzy-sdk
or YARN
yarn add @modzy/modzy-sdk
Initialize your client by authenticating with an API key. You candownload an API Key from your instance of Modzy.
import{ModzyClient}from"@modzy/modzy-sdk";constmodzyClient=newModzyClient({apiKey:"Valid Modzy API Key",//e.g., "JbFkWZMx4Ea3epIrxSgA.a2fR36fZi3sdFPoztAXT"url:"Valid Modzy URL",//e.g., "https://trial.app.modzy.com"});
Submit an inference job to a text-based model by providing the model ID, version, and raw input text.
//Submit text to v1.0.1 of a Sentiment Analysis model, and to make the job explainable, change explain=Trueconst{ jobIdentifier}=awaitmodzyClient.submitJobText({modelId:"ed542963de",version:"1.0.1",sources:{firstPhoneCall:{"input.txt":"Mr Watson, come here. I want to see you.",},},});
Pass a file from your local directory to a model by providing the model ID, version, and the filepath of your sample data:
// Submit a job to the Image-Based Geolocation modelconst{ jobIdentifier}=awaitmodzyClient.submitJobFile({modelId:"aevbu1h3yw",version:"1.0.1",sources:{nyc-skyline:{image:"./images/nyc-skyline.jpg",},},});
Convert images and other large inputs to base64 embedded data and submit to a model by providing a model ID, version number, and dictionary with one or more base64 encoded inputs:
constfs=require('fs');//Embed input as a string in base64constimageBytes=fs.readFileSync('images/tower-bridge.jpg');//Prepare the source dictionaryletsources={"tower-bridge":{"image":imageBytes}};//Submit the image to v1.0.1 of an Imaged-based Geolocation modelconst{ jobIdentifier}=awaitmodzyClient.submitJobEmbedded("aevbu1h3yw","1.0.1","application/octet-stream",sources);
Submit data from a SQL database to a model by providing a model ID, version, a SQL query, and database connection credentials:
//Add database connection and query informationconstdbUrl="jdbc:postgresql://db.bit.io:5432/bitdotio"constdbUserName=DB_USER_NAME;constdbPassword=DB_PASSWORD;constdbDriver="org.postgresql.Driver";//Select as "input.txt" becase that is the required input name for this modelconstdbQuery="SELECT \"mailaddr\" as \"input.txt\" FROM \"user/demo_repo\".\"atl_parcel_attr\" LIMIT 10;";//Submit the database query to v0.0.12 of a Named Entity Recognition modelconst{ jobIdentifier}=awaitmodzyClient.submitJobJDBC("a92fc413b5","0.0.12",dbUrl,dbUserName,dbPassword,dbDriver,dbQuery)}
Submit data directly from your cloud storage bucket (Amazon S3 supported) by providing a model ID, version, and storage-blob-specific parameters.
//Define sources dictionary with bucket and key that points to the correct file in your s3 bucketconstbucketName="s3-bucket-name";constfileKey="key-to-file.txt";letsources={"sampleText":{"input.txt":{'bucket':bucketName,'key':fileKey}}};constaccessKey=ACCESS_KEY_ID;constsecretAccessKey=SECRET_KEY;constregion="us-east-1";//Submit s3 input to v1.0.1 of a Sentiment Analysis modelconst{ jobIdentifier}=awaitmodzyClient.submitJobAWSS3("ed542963de","1.0.1",accessKey,secretAccessKey,region,sources)
Hold until the inference is complete:
awaitmodzyClient.blockUntilJobComplete(jobIdentifier);
Get the output results:
constresult=awaitmodzyClient.getResult(jobIdentifier);
samples
provides details for specific use cases and are intended to be run using Node.js, but most can also run in the browserreact examples
contains react components that can be used to the browser to send files to, or retrieve files from Modzy.
To run these examples, make sure to updateAPI_KEY
andMODZY_URL
to valid values.
The Jest tests expect that there is a .env file at the root of the repo that contains a valid Modzy api key like this:
API_KEY=xxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxx
Modzy's SDK is built on top of theModzy HTTP/REST API. For a full list of features and supported routes visitJavaScript SDK on docs.modzy.com
For support, emailopensource@modzy.com or join ourSlack.
Contributions are always welcome!
Seecontributing.md
for ways to get started.
Please adhere to this project'scode of conduct
.
We are happy to receive contributions from all of our users. Check out our contributing file to learn more.
About
The official JavaScript SDK for the Modzy Machine Learning Operations (MLOps) Platform.
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors8
Uh oh!
There was an error while loading.Please reload this page.