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.

Tests:

To run tests: python .\test.py

To change tests, update test.json, then run: python .\test.py --save_tests Finally, copy test_output.json to test.json and run python .\test.py To verify

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.2.tar.gz (47.2 kB view details)

Uploaded Source

Built Distribution

promptgen-0.0.2-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for promptgen-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cc7892ba650c5d6830ab0a5373453b8fa3317993f172b975659a847bb1354b91
MD5 33539b32cde1c3ff7c7913a6c7118249
BLAKE2b-256 a28ae1f7609473c84e74ea0001807dbd3c7484738a58ae9e28bc338a69eb6a12

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for promptgen-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f5f52bbf1c89d956902f9729f966699323d8349104af73b6b4740effa4191e04
MD5 44fbfccd1348fb39629f3e4a57b500ea
BLAKE2b-256 4d524c50097e033803a62f550ab7064ecbb5939e0797a527734d4328efc81abc

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