npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@modzy/modzy-sdk

v2.0.1

Published

Javascript SDK for Modzy

Downloads

7

Readme

Modzy JavaScript SDK

Modzy's Javascript SDK simplifies tasks such as querying models, submitting jobs, and returning results. It supports both Node.js and browser JavaScript applications using the output target of your build system to know which code to use.

Visit docs.modzy.com for docs, guides, API and more.

These instructions are for Modzy JavaScript SDK v2, which is substantially different from v1.


Installation

From the command line in your project directory, run yarn add @modzy/modzy-sdk or npm install @modzy/modzy-sdk. Then import the ModzyClient class into your code:

yarn add @modzy/modzy-sdk
# or
npm install @modzy/modzy-sdk
import { ModzyClient } from "@modzy/modzy-sdk";

Initialize

To initialize ModzyClient, you need an api key. If using an installation of Modzy other than app.modzy.com, you'll also need to provide the url for your instance of Modzy. For debugging purposes, you can also turn on logging.

⚠️ Warning: Keep your API key secret. Do not include it in a git repo or store it on GitHub

// app.modzy.com
const modzyClient = new ModzyClient({
  apiKey: "xxxxxxxxxxxxx.xxxxxxxxxxxxx",
});

// or for private Modzy instances
const modzyClient = new ModzyClient({
  apiKey: "xxxxxxxxxxxxx.xxxxxxxxxxxxx",
  url: "https://modzy.yourdomain.com",
});

Basic usage

Submit a job providing the model, version and input text:

const { jobIdentifier } = await modzyClient.submitJobText({
  modelId: "ed542963de",
  version: "1.0.1",
  sources: {
    yourInputKey: {
      "input.txt": "Sometimes I really hate ribs",
    },
  },
});

Hold until the inference is complete:

await modzyClient.blockUntilJobComplete(jobIdentifier);

Get the output results:

const result = await modzyClient.getResult(jobIdentifier);

Samples

Check out our samples for details on specific use cases. Samples are intended to be run using Node.js, but most can also run in the browser. The react examples directory contains a couple of react components to show how you can use the browser to send files to, or retrieve files from Modzy. To run the samples using app.modzy.com, make sure to update the line const API_KEY = process.env.MODZY_API_KEY; to contain a real api key from your account.


Running tests

The Jest tests expect that there is a .env file at the root of the repo that contains a valid app.modzy.com api key like this:

API_KEY=xxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxx

Contributing

We are happy to receive contributions from all of our users. Check out our contributing file to learn more.


Code of conduct

Please see our code of conduct for any questions about the kind of community we are trying to build. Contributor Covenant