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

completion-cli

v2.0.1

Published

Complete, explain or summarize text or files querying OpenAI models

Downloads

96

Readme

completion-cli

NPM version build status Test coverage npm download

npx completion-cli --help

Answers questions. This tool was done for personal use, but feel free to use it.

Requirements

  • NodeJS v19+

Api

  • Define OPENAI_API_KEY environment variable with your OpenAI key.
  • Simplest one. Request creative reply of 2000 tokens long.
npx completion-cli -t 2000 -T 1 -p "Explain me the world:"
  • Send the text from blogpost.txt using supported option in the config file.

I tend to use this option almost exclusively.

npx completion-cli -j ./path/to/config.json -f ./path/to/blogpost.txt

Example of a json config here

Options

Pass either cli flags or a JSON-config path. The CLI and JSON options are combined, CLI overwrites JSON. But only one of --prompt or --filePath or json.prompt is allowed.

  • --help
  • --filePath or -f, the relative path to the text file. Example: completion-cli -f ./path/to/blogpost.txt
  • --jsonConfig or -j, path to a json file with any of the [Open AI Supported Options](#supported-onot both, and any of these overwrites ptions). Example: completion-cli -j ./path/to/config.json

The CLI only supports a small subset of OpenAI options

  • --prompt or -p: one way to pass text. Example: completion-cli -p Explain me the world: . The length limit is 15000 bytes (ascii characters.)
  • --model or -m, the default model used is text-davinci-003. Other flavours are: text-curie-001, text-babbage-001. Default text-davinci-003
  • --tokens or -t the expected response length in tokens (max is 4096, about 1700 english words.)`
  • --temperature or -T (capital T). How creative the model is. Float between 0 and 1. Default 0.
  • --echo or -e. Explicit boolean. Indicates whether to concatenate the response to the prompt or not. You need to specify --echo [true, false]

All the values in the object are optional. For explanations and default values check the schema file.

{
  "model": string;
  "prompt": string;
  "suffix": string;
  "max_tokens": number;
  "temperature": number;
  "top_p": number;
  "echo": boolean;
  "stop": string | string[];
  "presence_penalty": number;
  "frequency_penalty": number;
  "prePromptString": string;
  "postPromptString": string;
}

ToDos

  • [ ] Support different text encoding for filePath (streams have option for this)
  • [ ] Improve boolean flags (atm you have to specify --flagName true/false).
  • [ ] Support multiple completions from json configuration using the option n.
  • [ ] Support for stream option.
  • [ ] Support pdf.
  • [ ] Support both from urls as well.

The code is being thought such that it is not too difficult to adapt it to the browser.

License

MIT

There are no restrictions and you can do with the code what you prefer.