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

starcoder-cli

v1.0.0

Published

A CLI wrapper for code generation using the Hugging Face inference API

Downloads

4

Readme

starcoder-cli 🌟

License: ISC js-semistandard-style

This is an example of a simple CLI wrapper for the StarCoder code LLM using the Hugging Face inference api and wrapper library in node.js. This exposes the model's capabilities in a simple program inspired by old-school, text-based Unix tools and Github Copilot.

Features

  • AI code generation at the command line!

  • Saves your Hugging Face API access token locally in your home directory for subsequent runs

  • Composable with other command-line tools using pipes, redirection, etc.

  • it's free!

Installation

Requires:

  • Node.js >= 18
  • an account on the Hugging Face hub 🤗

Steps:

  1. Accept the conditions for the bigcode/starcoder model and create a personal access token if you do not already have one.
  2. Run npm install -g starcoder-cli to install the CLI globally
  3. You will be prompted for your API access token the first time you run the command (this will be stored locally for subsequent runs).

Usage

~$ starcode --help
Usage: starcode [options] <code to complete>

Options:
      --version  Show version number                                   [boolean]
  -f, --file     Specify a file to get text input from                  [string]
      --help     Show help                                             [boolean]

For example:

~$ starcode "def print_hello_world():"
def print_hello_world():
    print("Hello World")

def print_hello_world_twice():
    print

Realistically, you'll probably want to use a source code file as the input instead of trying to enter large amounts of code as a command-line argument. For this, use the -f flag and provide a path to the existing (but incomplete) source code file. You can also use also redirect output to a file with shell redirection:

~$ starcode -f example.py > new_example.py

(this may fail with larger input files)

You can also use shell pipes with the starcode command. For example, this command reads the generated code aloud on macOS:

$ starcode -f new_example.py | say

Prompting Tips

  • The StarCoder model used by this CLI is a text-completion model and is not tuned for instruction following or chat
  • However, you may be able to use comments as a form of quasi-instructions that the model has exposure to from its training dataset
  • Refer to the model paper (see "Further Reading" section) for the authors' dicussion of the model's limitations
  • Code produced by this tool may have vulnerabilities or bugs

Contributing 🤝

Contributions are welcome and encouraged! Feel free to submit a PR if you have any improvements!

For now, I am using semistandard to check and fix style issues (this may change in the future).

Thank you in advance to anyone that wants to help with this project.

License

This project is licensed under the ISC license.

Acknowledgments 🙏

Thank you to BigCode project for the model that inspired this and Hugging Face

Further Reading