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

is-true-that

v1.0.2

Published

Is it true that? A AI-based check utility library for JavaScript. Check the truth of any kind of statement.

Downloads

65

Readme

Is True That

is-true-that is the most serious library you'll ever need to determine if something is true. Or not. Seriously. Given an object and a natural language condition, it evaluates whether it is true or false.

npm downloads testing npm version Beta In Progress

What is this?

Free, funny and (maybe) useful truth testing tool

This library is designed to bring a bit of humor to your coding experience while providing a straightforward way to assess truthiness in your JavaScript applications.

In short, you can test the veracity of anything you like.

Important: This is a beta release. Accuracy is not guaranteed, and computing speed is relatively slow. Please refer to the Timing section for details.

Installation

npm install is-true-that

Usage

This library is easy to import and use. The basic usage involves the isTrueThat function, where you pass an object and a natural language statement, receiving true if the condition holds, and false otherwise.

const isTrueThat = require('is-true-that');

console.log(isTrueThat({ food: 'pizza', toppings: ['cheese', 'pepperoni'] }, 'is it a pizza with pepperoni')); // true
console.log(isTrueThat({ food: 'pizza', toppings: ['cheese', 'pepperoni'] }, 'is it a pizza with pepperoni but without cheese and tomatoes')); // false
console.log(isTrueThat(7, 'is it a prime number')); // true
console.log(isTrueThat(1000, 'is this the number of soldiers in a Roman legion?')); // false
console.log(isTrueThat({ animal: 'snake', length: 5 }, 'is it 3+2 meters long?')); // true

For more advanced usage, you can configure LLM (Large Language Model) options, timing, verbosity, and capabilities:

import { isTrueThat, initModel } from 'is-true-that';

async function main() {
    const options = {
        verbose: true,
        modelName: 'your-model-name-here'
    };

    // Initialize a model
    options.model = await initModel(options);

    // These requests share the same chat, speeding up computation
    console.log(await isTrueThat({ food: 'pizza', toppings: ['cheese', 'pepperoni'] }, 'is it a pizza with pepperoni', options)); // true
    console.log(await isTrueThat({ food: 'pizza', toppings: ['cheese', 'pepperoni'] }, 'is it a pizza with pepperoni but without cheese and tomatoes', options)); // false
    console.log(await isTrueThat(7, 'is it a prime number', options)); // true
    console.log(await isTrueThat(1000, 'is this the number of soldiers in a Roman legion?', options)); // false
    console.log(await isTrueThat({ animal: 'snake', length: 5 }, 'is it 3+2 meters long?', options)); // true
}

main();

Caution: Each isTrueThat function call initializes a new model or chat session if they are not provided in the options.

Why?

Sometimes you just need to know if something is true. And sometimes, you need a good laugh.

On a more serious note, in certain situations, such as dynamic user inputs, you may require a quick truth assessment based on natural language queries without having to implement complex logic. LLMs can be useful for evaluating such truths!

Features

  • 82% Accuracy: Generally tells you if something is true or not.
  • Lightweight: No unnecessary bloat (basic model requires 2GB of disk space and up to 4GB of RAM).
  • Humorous: Because why not?

Timing

We ran 150 test cases using npm test and found that the average execution time is 16,834ms with a standard deviation of 5,230ms. Longer execution times occur when the context window exceeds 1,000 tokens, which can take up to 16 seconds to recover (typically every 5-10 requests). This can be mitigated by clearing the chat or increasing the number of context tokens.

Sample Test Results

| Test Case | Description | Expected Result | Actual Result | Pass/Fail | |-----------|-------------|-----------------|---------------|-----------| | 1 | Pizza with pepperoni | true | true | Pass | | 2 | Pizza with pepperoni but without cheese and tomatoes | false | false | Pass | | 3 | Prime number check for 7 | true | true | Pass | | 4 | Roman legion soldiers count | false | false | Pass | | 5 | Snake length check | true | true | Pass |

These results demonstrate the accuracy and reliability of the is-true-that library in various scenarios.

Models

Is True That uses orca-mini-3b-gguf2-q4_0.gguf as base model which is a performant but non-commercial model offered with gpt4all. It weights 2GB and will be installed once and then cached. It requires 4GB of RAM to be executed locally.

For more consistent results, we suggests Llama 3 8B Instruct or heavier models. More information at gpt4all-models.

Other

Contributing

  1. Fork the repository!
  2. Create a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request!

License

MIT


Made with ❤️ and a sense of humor.