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

jgpt

v0.0.3

Published

The jgpt npm package enables developers to utilize OpenAI's GPT models within JavaScript. By providing intuitive methods for natural language processing, it simplifies common programming tasks.

Downloads

1

Readme

This is a WIP. Right now the return object will most of the time be unusuable

My intention is the following: jgpt.includes("Hello, World!", "World", 7) -- GPT Response: true

Current output: jgpt.includes("Hello, World!", "World", 7) -- GPT Response: Sure! Here's a Python code snip...

JGPT Documentation

JGPT leverages OpenAI's GPT models to allow developers to use natural language processing (NLP) directly within JavaScript. It emphasizes idea over syntax, providing a more intuitive approach to programming.

Installation

Before using JGPT, you must obtain a valid API key from OpenAI and understand OpenAI's pricing details.

Classes

class JGPT

The main class that holds all the methods for interacting with natural language.

Constructor

constructor(apiKey, orgId)
Parameters
  • apiKey (String) - Your OpenAI API key.
  • orgId (String) - Your OpenAI organization ID.

Methods

Custom Methods
  • command(object, command) This method takes an object and a command as inputs and sends them as a part of a prompt to the GPT model. The object is serialized into a JSON string, and the command is concatenated to form the complete prompt. It then awaits the response from the model.

  • talk(prompt) This method takes a prompt as input and sends it to the GPT model. It is a straightforward way to engage in a conversation with the model, providing the prompt and awaiting the response.

String Methods

String Methods

  • includes(string, searchString, position): Checks if a string includes another at a specific position.
  • indexOf(string, searchValue, fromIndex): Finds the index of a value in a string.
  • lastIndexOf(string, searchValue, fromIndex): Finds the last index of a value in a string.
  • match(string, regexp): Matches a string with a regular expression.
  • replace(string, searchValue, replaceValue): Replaces a value in a string with another.
  • slice(string, beginIndex, endIndex): Slices a string between two indices.
  • split(string, separator, limit): Splits a string by a separator with an optional limit.
  • substr(string, start, length): Gets a substring starting at a specific index with a specific length.
  • toUpperCase(string): Converts a string to uppercase.
  • toLowerCase(string): Converts a string to lowercase.
  • trim(string): Trims whitespace from a string.
Array Methods
  • concat(array, ...values): Concatenates values to an array.
  • every(array, callback): Checks every element with a callback.
  • filter(array, callback): Filters an array with a callback.
  • find(array, callback): Finds an element in an array with a callback.
  • findIndex(array, callback): Finds an index in an array with a callback.
  • forEach(array, callback): Applies a callback to each element in an array.
  • indexOf(array, searchElement, fromIndex): Finds the index of a value in an array.
  • join(array, separator): Joins an array with a separator.
  • lastIndexOf(array, searchElement, fromIndex): Finds the last index of a value in an array.
  • map(array, callback): Maps an array with a callback.
  • pop(array): Pops the last element from an array.
  • push(array, ...elements): Pushes elements to an array.
  • reduce(array, callback, initialValue): Reduces an array with a callback and initial value.
  • reverse(array): Reverses an array.
  • shift(array): Shifts the first element from an array.
  • slice(array, beginIndex, endIndex): Slices an array between two indices.
  • some(array, callback): Checks if some elements in an array satisfy a callback.
  • sort(array, compareFunction): Sorts an array with a compare function.
  • splice(array, start, deleteCount, ...items): Splices an array starting at an index, deleting a count, inserting items.
  • unshift(array, ...elements): Unshifts elements to an array.
Number Methods
  • toExponential(number, fractionDigits): Converts to exponential form with specific fraction digits.
  • toFixed(number, digits): Fixes to specific decimal places.
  • toLocaleString(number, locales, options): Converts to a locale string with locales and options.
  • toPrecision(number, precision): Converts to a specific precision.
Date Methods
  • getDate(date): Gets the date.
  • getDay(date): Gets the day.
  • getFullYear(date): Gets the full year.
  • getHours(date): Gets the hours.
  • getMilliseconds(date): Gets the milliseconds.
  • getMinutes(date): Gets the minutes.
  • getMonth(date): Gets the month.
  • getSeconds(date): Gets the seconds.
  • getTime(date): Gets the time.

class Conversation

A helper class to manage ongoing conversations with JGPT.

Methods

  • continueConversation(context): Continues a conversation with JGPT.
  • start(context): Starts a new conversation with JGPT.

Usage Example

const JGPT = require('jgpt');
const jgpt = new JGPT('your-api-key', 'your-org-id');
jgpt.includes("Hello, World!", "World", 7).then(result => console.log(result.javascriptOutput));

Conclusion

JGPT offers a unique way to interact with JavaScript using natural language, making development more approachable and user-friendly. Whether you're a seasoned developer or just getting started, JGPT brings the power of AI-driven language models directly to your JavaScript environment.