Giter VIP home page Giter VIP logo

prompto's Introduction

Prompto ✒️

Programatically construct ChatGPT prompts with Typescript. Think of it as a SQL query builder except instead of SQL queries, its LLM prompts.

Features

  • ✅ Zero dependencies
  • ✅ Resistant to prompt injection
  • ✅ Blazingly fast prompt generation

Installation

npm install ts-prompto

Usage

Create a Prompto object anywhere and use method chaining to build your prompt:

const prompt = new Prompto()
  .withPersona("Openai engineer")
  .withInstruction("Explain how to write effective ChatGPT prompts")
  .inFormat("step-by-step guide")
  .generatePrompt();

console.log(prompt);

API

Prompto()

Creates an empty prompt config with a blank instruction.

withPersona(persona: string)

Sets the persona that the model will take on.

withInstruction(question: string)

Sets the main instruction or request the model will respond to. This is a compulsory method.

withContext(context: string)

Provides additional context or information for the model to consider while generating a response.

withText(content: string[])

Adds any text that the model needs to parse through (i.e., an article to summarize or a code snippet to explain).

withSteps(steps: string[])

Adds the specific set of steps required to reach an output. Helpful for guiding the model to reach its output, allowing the model to 'think' more about its response.

withExamples(examples: string[])

Adds a list of example outputs for the model to be aware of via few-shot prompting. Helpful if you need a specific or complicated output.

inFormat(format: string)

Adds the expected format of the response (i.e., step-by-step instructions, JSON, TypeScript code, etc.)

withCriteria(criteria: string[])

Adds a list of rules that the model must follow to reach its output. Helpful for setting constraints on what the output should not include or for handling cases for user-inputted instructions.

inTone(tone: string)

Sets the tone of the response. Helpful if you're writing text that requires an appropriate tone, such as an email.

generatePrompt()

Generates the prompt using the prompt config. This is the final method that should be called in the chain. Also clears the prompt config before returning the prompt string, allowing for the same Prompto instance to be used for generating different prompts.

prompto's People

Contributors

p0u4a avatar

Stargazers

Bartosz Golebiowski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.