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

promptman

v0.0.13

Published

Promptman is a small helper class for repetitive prompt engineering techniques

Downloads

15

Readme

This mini package provides helper methods to interact with a language model like ChatGPT, to generate some repititive prompt engineering techniques. the why behind it, is I got tired of writing the same context around my needed prompt. Extend it if you like it.

https://www.npmjs.com/package/promptman

npm install promptman

The Promptman class has the following public methods:

  1. resetInstructions() - resets the prompt attribute.

  2. zeroShotCOT() - sets the prompt attribute for generating a response for a zero-shot chain of thought.

  3. sentiment() - sets the prompt attribute for generating a sentiment analysis of text.

  4. stopWhenInDoubt - makes sure GPT would only answer when its facutal knowlledge

  5. toResponseType() - sets the type of response to be returned.

  6. toJson() - sets the type of response to JSON format.

  7. text() - returns the text after executing any method.

The Promptman class is initialized with a prompt parameter and is used to interact with GPT or any LLM simply. The class methods can be called in a step-by-step manner to generate text for various purposes like sentiment analysis and zero-shot chain of thought.

Example 1:

import { Promptman } from "promptman"
const text = new Promptman("what are the steps to make a cup of coffee?")
                    .resetInstructions()
                    .zeroShotCOT()
                    .toJson("{ steps: [number: 1, text: 'boil water']}")
                    .text()

Text generated

Ignore all previous instructions.
what are the steps to make a cup of coffee?
Lets think step by step.
return the response in the JSON,
and make sure you don't return anything else
but JSON , example: { steps: [number: 1, text: 'boil water']}.

Result

{
  "steps": [
    {
      "number": 1,
      "text": "Fill a kettle or pot with fresh water and bring it to a boil."
    },
    {
      "number": 2,
      "text": "Grind coffee beans to a medium-fine consistency."
    },
    {
      "number": 3,
      "text": "Add ground coffee to a coffee filter or french press."
    },
    {
      "number": 4,
      "text": "Pour hot water over the coffee grounds and let it steep for 4-5 minutes."
    },
    {
      "number": 5,
      "text": "Slowly press french press plunger down or remove filter from coffee maker."
    },
    {
      "number": 6,
      "text": "Pour coffee into a mug and add milk, sugar, or other desired additions."
    },
    {
      "number": 7,
      "text": "Enjoy your delicious cup of coffee!"
    }
  ]
}

Example 2 - Stop when in doubt:

import { Promptman } from "promptman"
const text = new Promptman("what would be the best way to solve for global warming?")
                    .resetInstructions()
                    .zeroShotCOT()
                    .stopWhenInDoubt()
                    .toJson()
                    .text()

Text generated

Ignore all previous instructions.
what would be the best way to solve for global warming?
Lets think step by step.
If you don't have an answer or there is a probability your answer is wrong or the information is not based on factual knowledge, answer with 'I don't know'
return the response in the JSON,
and make sure you don't return anything else
but JSON .

Result

{
 "response": "I don't know"
}

Note: This README file was generated based on the latest version of the script available at the time of writing.