Skip to main content

Python Parser to generate lists of prompts from a line of script(s)

Project description

promptgen

Python Parser to generate lists of prompts from a line of script(s)

Description

Takes a string with code spans denoted with {{ }} and generates a list of prompts based on a batch size and count of batches. Useful for AI Image Generators.

Primary API:

def generate_prompts(template: str, batch_count = 1, batch_size = 1, callback_handler: CallbackHandler = None):

Var Commands

set_var("variable name") sets a variable that can be retrieved by a subsequent var("variable name") retrieves the value of a variable

Array Commands

list(name) retrieves array from named list rngi(min, max, [step], [tag_name]) retrieves an array of values from min to max [expr,expr,expr]: Constant array, separated by semicolons

Value Commands

rndi(min, max) returns a value (as string) from min to max (includes min and max), optimized version of randa(rngi(min, max)) rnda(array_cmd) returns a random value from an array nexta(array_cmd) returns the next item in an array, starting with 0, wrapping around if needed update_b( value_cmd ) calls cmd for every new batch, previous value otherwise. (same as update_c( cmd, batch_size )) update_c( value_cmd, c ) calls cmd whenever the (prompt count % c) == 0, previous value otherwise

ForEach Command

foreach( array_cmd, [repeat = 1], [index = 0]) Creates new prompts, which means batch_count will be ignored. The parser will walk through the current list of prompts, and repeat each item once (or more times if repeat > 1). expands will be processed in the order of the indexes, then in order they appear in the list.

Basic Math

{{2 + 3}} will generate 5, etc. Correct operator precedence in NYI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptgen-0.0.1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

promptgen-0.0.1-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file promptgen-0.0.1.tar.gz.

File metadata

  • Download URL: promptgen-0.0.1.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.6

File hashes

Hashes for promptgen-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f60d83653ffe43da546ac37e1942753e69f85664b7c347de72860b7c616783f9
MD5 791bcecb4ffebb77d9f7302d39f6efc6
BLAKE2b-256 c81ae58fd25c14caa7a7f338bdafa258d127723c75546744c97694fa8aedc670

See more details on using hashes here.

File details

Details for the file promptgen-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: promptgen-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.6

File hashes

Hashes for promptgen-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d526bae209dfd15a4b1f9f20699602f492a46768018de0d06f173ae25c206756
MD5 81ada65e5a182ef8b4b0fce71c4000e5
BLAKE2b-256 72ff18a359a077d234a45eaa0461de2dc3208025526c7134c1214c2d720ffbc9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page