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

@clarityhub/node-api

v0.0.3

Published

Clarity Hub Node API – Use NLP and USE quickly in your Node application

Downloads

8

Readme

@clarityhub/node-api

npm version Actions Status

Clarity Hub API utilities for NodeJS. Includes our NLP APIs and Infer Model APIs.

Installation

To install using npm:

npm i --save @clarityhub/node-api axios

Usage

You will need a Clarity Hub API account. Once you have an account, you will need to generate an access key.

const clarityhub = require('@clarityhub/node-api')({
    accessKeyId: process.env.ACCESS_KEY_ID,
    accessKeySecret: process.env.ACCESS_KEY_SECRET,
});

The clarityhub object has api and models properties that you can access.

Infer Models

A full example:

const myModel = await clarityhub.models.create({
    name: 'human readable name',
    description: 'your model description',
});

await myModel.train([
    { utterance: 'hello world', label: 'greeting' },
    { utterance: 'good morning', label: 'greeting' },
    { utterance: 'how do I login', label: 'auth' },
    { utterance: 'how do I reset my password', label: 'auth' },
]);

const predictions = await myModel.predictSimilar('hi there');
console.log('predicted similar utterance', predictions[0]);

const predictions = await myModel.predictLabel('hi there');
console.log('predicted label', predictions[0]);

You can also get the labels from a model and update the label text:

const labels = await myModel.getLabels();

console.log(labels.map((label) => {
    // userLabel is the user defined label
    // label is the model generated label
    return label.data.userLabel || label.data.label;
}));

// Override the text that the training model generated for this label
labels[0].update('override userLabel');

API

The clarityhub.api object has all the raw requests you can make to the Clarity Hub API, including our NLP APIs:

  • clarityhub.api.nlp.sentiment(utterances: [String]): AxiosResponse
  • clarityhub.api.nlp.toxicity(utterances: [String]): AxiosResponse
  • clarityhub.api.nlp.topics(utterances: [String]): AxiosResponse
  • clarityhub.api.nlp.embed(utterances: [String]): AxiosResponse

The object also has the raw requests you can make for infer models:

  • clarityhub.api.models.getAll(): AxiosResponse
  • clarityhub.api.models.create(payload: Object): AxiosResponse
  • clarityhub.api.models.get(modelId: String): AxiosResponse
  • clarityhub.api.models.update(modelId: String, payload: Object): AxiosResponse
  • clarityhub.api.models.delete(modelId: String): AxiosResponse

Model training APIs:

  • clarityhub.api.models.train(modelId: String, utterances: [Utterance]): AxiosResponse

Model label APIs:

  • clarityhub.api.models.labels.getAll(modelId: String): AxiosResponse
  • clarityhub.api.models.labels.get(modelId: String, labelId: String): AxiosResponse
  • clarityhub.api.models.labels.update(modelId: String, labelId: String, payload: Object): AxiosResponse

Model predict APIs:

  • clarityhub.api.models.predict.labels(modelId: String, utterances: [String]): AxiosResponse
  • clarityhub.api.models.predict.similar(modelId: String, utterances: [String]): AxiosResponse

For more specifics on the response data that these methods return, see our Swagger Documentation.

License

This repo is MIT Licensed, see LICENSE.