prope

package module
v0.0.0-...-18bfe25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 7 Imported by: 0

README

Prope

A library and CLI tool to generate permutations of LLM-Prompts based on template files and a dictionary.

Example

Given this template:

{{.Size}} {{.Colors}} colored {{.Animal}} wearing {{.Clothes}} , {{.Action}}, {{.Light}}

The following unique permutations can be generated:

"Robust Midnight Black colored Fox wearing Kilt , tennis, sconce"
"Squarish Granite Gray colored Snake wearing Robe , skateboarding, spotlight"
"Scrawny Marble colored Ostrich wearing Pajamas , rock climbing, spotlight"`

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Permutator

type Permutator struct {
	Template *template.Template
	Data     dict.DataPermutator
}

Permutator generates unique permutations of golang text/templates by mutating the variables in the template using list from a dictionary of values for each variable. The dictionary is loaded from json files. See the data folder for examples.

It can be used to batch generate a number of variable prompts for an LLM like stable-diffusion or chat-gpt

func NewPermutator

func NewPermutator(tplPathGlob string, dataPathGlob string) (*Permutator, error)

NewPermutator creates a new Permutator tplPathGlob is a glob pattern for the template files dataPathGlob is a glob pattern for the data files The data files are expected to be in json format, and the template files are expected to be in go template format

func (*Permutator) ForeachTemplateGen

func (p *Permutator) ForeachTemplateGen(n int) []string

ForeachTemplateGen generates a number of permutations for each template in the template set

func (*Permutator) GenN

func (p *Permutator) GenN(n int, tplName string) []string

GenN generates n permutations for a given template

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL