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

2.1.0 • Public • Published

prompt-tag

A prompt optimizer function designed as a tagged template literal.

Overview

Takes a template literal string and any number of arguments. The function tokenizes and stems the first literal string, then iterates over the arguments and appends them to the tokenized and stemmed string along with their synonyms (if any are found).

Usage

Simple:

import { prompt } from 'prompt-tag'

const res = await prompt`Take me on a journey to the ${'beautiful'} places in the ${'galaxy'}`
// tak me on a journey to the{beautiful,pleasant}plac in the{galaxy,collection,aggregation,accumulation,assemblage}

Using arrays:

const actions = ['write', 'advertising']
const styles = ['outdoor recreation', 'summertime']
const places = ['alaska', 'montana']
const reasons = ['new shoe model']
const got = await prompt`${actions} for all ${styles} and ${places} because of ${reasons}`
console.log(got)

// {write,advertising,create_by_mental_act,create_mentally,commercial_enterprise,business_enterprise,business}∀{outdoor recreation,summertime,outdoor recreation,season,time_of_year}∪{alaska,montana,American_state,American_state}∵ of{new shoe model,new shoe model}

See tests for more examples.

Author

Readme

Keywords

Package Sidebar

Install

npm i prompt-tag

Weekly Downloads

2

Version

2.1.0

License

MIT

Unpacked Size

9.06 kB

Total Files

9

Last publish

Collaborators

  • ch__tz