prompt-tag
v2.1.0
Published
A prompt optimizer function designed as a tagged template literal.
Downloads
5
Readme
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.