gptsam
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

GPTSAM

A CLI Wrapper on top of the ChatGPT API.

This CLI Package is based off the Node.js client for the official ChatGPT API.

Learn more about the

Intro

This package is a Node.js wrapper around ChatGPT by OpenAI. TS batteries included. ✨

Example usage

Usage

Sign up for an OpenAI API key and setup the CLI:

gptsam setup --token <your-openai-token>

You can also use your command line export functionality to store it in your environment.

export OPENAI_API_KEY="sk-TODO"
npx gptsam "your prompt here"

By default, the response is streamed to stdout, the results are stored in a local config file, and every invocation starts a new conversation. You can use -c to continue the previous conversation and --no-stream to disable streaming.

Usage:
  $ gptsam <prompt>

Commands:
  <prompt>  Ask ChatGPT a question
  rm-cache  Clears the local message cache
  ls-cache  Prints the local message cache path

For more info, run any command with the `--help` flag:
  $ gptsam --help
  $ gptsam setup --help
  $ gptsam rm-cache --help
  $ gptsam ls-cache --help

Options:
  -c, --continue          Continue last conversation (default: false)
  -d, --debug             Enables debug logging (default: false)
  -s, --stream            Streams the response (default: true)
  -s, --store             Enables the local message cache (default: true)
  -t, --timeout           Timeout in milliseconds
  -k, --apiKey            OpenAI API key
  -n, --conversationName  Unique name for the conversation
  -h, --help              Display this message
  -v, --version           Display version number

Install

npm i -g gptsam

Make sure you're using node >= 18 so fetch is available (or node >= 14 if you install a fetch polyfill).

Caveats

This project uses the ChatGPTAPI class which relies on the gpt-3.5-turbo-0301 model with the official OpenAI chat completions API (official, robust approach, but it's not free). You can override the model, completion params, and system message to fully customize your assistant.

Compatibility

  • This package is ESM-only.
  • This package supports node >= 14.
  • This module assumes that fetch is installed.
    • In node >= 18, it's installed by default.
    • In node < 18, you need to install a polyfill like unfetch/polyfill (guide) or isomorphic-fetch (guide).
  • If you want to build a website using chatgpt, we recommend using it only from your backend API

Credits

License

MIT © Andrew Miracle

Package Sidebar

Install

npm i gptsam

Weekly Downloads

0

Version

1.4.0

License

MIT

Unpacked Size

101 kB

Total Files

7

Last publish

Collaborators

  • koolamusic