Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The official JavaScript SDK for the Modzy Machine Learning Operations (MLOps) Platform.

License

NotificationsYou must be signed in to change notification settings

modzy/sdk-javascript

Repository files navigation

Installation

Intall Modzy's JavaScript SDK with NPM

npm install @modzy/modzy-sdk

or YARN

yarn add @modzy/modzy-sdk

Usage/Examples

Initializing the 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"});

Running Inferences

Raw Text Inputs

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.",},},});

File Inputs

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",},},});

Embedded Inputs

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);

Inputs from Databases

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)}

Inputs from Cloud Storage

Submit data directly from your cloud storage bucket (Amazon S3 supported) by providing a model ID, version, and storage-blob-specific parameters.

AWS S3

//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)

Getting Results

Hold until the inference is complete:

awaitmodzyClient.blockUntilJobComplete(jobIdentifier);

Get the output results:

constresult=awaitmodzyClient.getResult(jobIdentifier);

SDK Code Examples

  • samples provides details for specific use cases and are intended to be run using Node.js, but most can also run in the browser
  • react 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.

Running Tests

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

Documentation

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

Support

For support, emailopensource@modzy.com or join ourSlack.

Contributing

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.

Contributor Covenant


[8]ページ先頭

©2009-2025 Movatter.jp