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

adaptjs

v1.0.3

Published

a javascript wrapper around MycroftAI/adapt

Downloads

12

Readme

adaptjs

A nodejs wrapper around the Adapt Intent Parser from Mycroft, which converts natural language into structured intents based on intent definitions.

Installation

$ npm install --save adaptjs

Install MycroftAI/adapt as described in their README.

Example

"use strict";
const EngineBuilder = require("adaptjs").EngineBuilder;

let builder = new EngineBuilder();

builder.entity("WeatherKeyword", ["weather"]);
builder.entity("WeatherType", ["snow", "rain", "wind", "sleet", "sun"]);
builder.entity("Location", ["Seattle", "San Francisco", "Tokyo"]);

builder.intent("WeatherIntent")
	.require("WeatherKeyword", "weatherkey")
	.optionally("WeatherType")
	.require("Location");

let engine = builder.build();

engine.query("Whats the weather in San Francisco today?")
.then(intents => { console.log(intents); engine.stop(); })
.catch(error => { console.log(error); console.log(error.stack); engine.stop(); });

/* [ { intent_type: 'WeatherIntent',
    weatherkey: 'weather',
    Location: 'San Francisco',
    confidence: 0.4878048780487805,
    target: null } ] */

See examples/ for more examples of the API and MycroftAI/adapt for more information about the Adapt Intent Parser itself.

API

new EngineBuilder([adaptInstallationPath]): EngineBuilder
EngineBuilder.entity(name, arrayOfValues): Entity
EngineBuilder.regexEntity(pattern): RegexEntity
EngineBuilder.intent(name): Intent
EngineBuilder.build(): Engine

Intent.require(entity, [attributeName]): this
Intent.optionally(entity, [attributeName]): this

Engine.start()
Engine.stop()
Engine.isRunning(): bool
Engine.query(input): Promise

How it works

The EngineBuilder on the JavaScript side creates a definition of all entities and intents and passes it to a python child process as JSON. The python child process keeps running in the background and receives new input over stdin. You have to stop the child process manually using engine.stop().

If you have installed Adapt in a specific location (not your current-working-directory), then you can pass that path as the first argument of the EngineBuilder. This path should be absolute, because otherwise it will be relative out of node_modules/ which will lead to problems later on.