Code Monkey home page Code Monkey logo

klasifikasi-js's Introduction

Klasifikasi for Node.js

Official Klasifikasi API Client Library

Requirement

Node v12 or later

Installation

npm install klasifikasi-js

Quick start

You will need valid clientId & clientSecret of your model. You can get those from credential section at your model page, which is both unique per model.

import Klasifikasi from "klasifikasi-js";

await Klasifikasi.build({
  creds: [
    {
      clientId: "client-id",
      clientSecret: "client-secret",
    },
  ],
});

You can pass multiple clientId & clientSecret too

import Klasifikasi from "klasifikasi-js";

await Klasifikasi.build({
  creds: [
    {
      clientId: "client-id-1",
      clientSecret: "client-secret-1",
    },
    {
      clientId: "client-id-2",
      clientSecret: "client-secret-2",
    },
  ],
});

Classify

You will need your model publicId to start classifying with your model. You can get your model publicId from you model page, or you can get it from here :

const models = Klasifikasi.getModels();
console.log(models);
/*
the output should be like this
  {
    [publicId: string]: {
      name: string,
      credential: {
        clientId: string,
        clientSecret: string,
        token: string,
        expiredAt: number
      },
      tags: {
        name: string,
        description: string | null,
        descriptionWeight: string | null
      }[]
    }
  }
*/

classifying example

const result = await Klasifikasi.classify("publicId", "query");
console.log(result);
/*
the output should be like this
  {
    result: {
      label: string,
      score: number
    }[]
  }
*/

or with dynamic tags

const result = await Klasifikasi.zslClassify(
  "publicId",
  "query",
  ["tag1", "tag2", "etc"],
  multiClass
);
console.log(result);
/*
the output should be like this
  {
    result: {
      label: string,
      score: number
    }[]
  }
*/

QaModel find

const result = await Klasifikasi.qamodelFind('Cara logging di javascript bagaimana ?', 'Cara logging pada javascript adalah console.log()')
console.log(result)
/** The output should be like this
    [
      {
        answer: string,
        context: string,
        end: number,
        score: number,
        start: number
      }
    ] */

QaModel bulk find

const result = await Klasifikasi.qamodelBulkFind([
      {
        question: 'Kapan indonesia merdeka?',
        context: 'Indonesia merdeka pada tanggal 17 Agustus 1945'
      },
      {
        question: 'Hai ini rakyat indonesia memperingati hari kemerdekaan mereka yang ke berapa?',
        context: 'Bulan ini, rakyat Indonesia akan memperingati hari kemerdekaan mereka yang ke 70 pada tanggal 17 Agustus'
      }
    ])
console.log(result)
/** The output should be like this
{
  result: [
    {
      answer: {
        answer: string,
        end: number,
        score: number,
        start: number
      },
      context: string,
      question: string,
    },
    ...
  ]
} */

Logs

You can get your classifying logs based on your model publicId

const logs = Klasifikasi.logs("publicId", {
  startedAt: new Date("1 December 2020"),
  endedAt: new Date("2 December 2020"),
  take: 100,
  skip: 0,
});
console.log(logs);
/*
the output should be like this
 {
   histories: {
     createdAt: Date,
     updatedAt: Date,
     deletedAt: Date,
     id: number,
     model: string,
     modelResult: {
       label: string,
       score: number
     }[]
     modelCurrentName: string,
     ipInfo: {
       ip: string
     },
     userId: number,
     aiModelId: number,
   }[],
   length: number
 }
*/

endedAt & startedAt parameter is mandatory, the rest is optional.

Error

All the function above will throw an error if something bad happen. The error object will have the same structure.

{
  status?: number // http status codes,
  body: {
    error: string
  }
}

klasifikasi-js's People

Contributors

zesagata avatar restyled-commits avatar mgilangjanuar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.