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

chatgpt.js

v0.0.6

Published

A simple wrapper to allow integration with the ChatGPT beta.

Downloads

4

Readme

chatgpt.js

Interact with OpenAI's ChatGPT unofficial API programatically.


Getting Started

To start using chatgpt.js in your project, follow this quick guide:

  1. Add the package with npm i chatgpt.js -S or yarn add chatgpt.js
  2. Refer to the example code below to integrate:

index.js

const GPTChat = require("../dist");
const { authToken } = require("./config");
const sleep = require("util").promisify(setTimeout);

const chatgpt = new GPTChat.Client({ authToken });

chatgpt.once("ready", async () => {
    let resp = await chatgpt.call("hello there!").catch(e => console.log(e));
    if(!resp) return console.error("looks like something went wrong :(");
    console.log(resp);

    await sleep(10000);
    
    resp = await chatgpt.call("what is the scientific name for the common house finch?", resp.conversation).catch(e => console.log(e));
    if(!resp) return console.error("looks like something went wrong :(");
    console.log(resp);
});

chatgpt.on("debug", m => console.log(`DEBUG: ${m}`));
chatgpt.on("error", m => console.error(`ERROR: ${m}`));

/*
    Output:

    DEBUG: sessionKey updated to: (...)fqJbBV3WQ.W8IAmqiEwjO-Uyw9ub2Zsg
    {
        text: 'Hello! How can I help you today?',
        conversation: '4e294a80-5daf-4322-8077-dc4d58affa1a',
        parent_message: 'a5f3b506-232a-414f-999a-161cd1ee26b3'
    }
    DEBUG: sessionKey updated to: (...)FTpYIborA.5t64dn9PjQsM-abpr1GaYw
    DEBUG: Found cached conversation: {"id":"4e294a80-5daf-4322-8077-dc4d58affa1a","parent_id":"a5f3b506-232a-414f-999a-161cd1ee26b3"}
    {
        text: 'The scientific name for the common house finch is Haemorhous mexicanus. This species is a small, seed-eating bird native to North America. It is often found in urban and suburban areas, where it feeds on a variety of seeere it feeds on a variety of seeds and other plant material. The male of the species is easily recognizable by its bright red head and breast.',
        conversation: '4e294a80-5daf-4322-8077-dc4d58affa1a',
        parent_message: 'ab4ff136-625f-41d9-b283-2c154230b76e'
    }
*/

config.js

module.exports = {
    authToken: "YOUR-OPENAI-ACCESS-TOKEN"
}

Contributing

Before creating an issue, please ensure that it hasn't already been reported / suggested. If you would like to contribute to the codebase, please do! Fork this repository, add your edits, and submit a pull request.


License

chatgpt.js is licensed under the GPL 3.0 license. See the LICENSE file for more information. If you plan to use any part of this source code in your own bot, I would be grateful if you would include some form of credit somewhere.


Finally

Thank you so much for visiting! I hope that my code is useful to you. I'd really appreciate a ⭐ if this helped you out. Cheers! 😄