Skip to main content

Write dynamic LLM prompts as natural language

Project description

Promptu

Write dynamic LLM prompts as natural language

Promptu provides a suite of natural language generation utilities for prompt engineers, such as truncation, pluralization and natural language list formatting.

Project Status

:warning: This project is currently in its infancy. Please report bugs and expect breaking changes.

Installation

pip install promptu

Example

from promptu import join

def find_matching_color(existing_colors):
    return f'What color goes well with {join(items=existing_colors, conjunction="and")}?'

# Prints "What color goes well with blue, purple and white?"
print(find_matching_color(['blue', 'purple', 'white']))

Using in Langchain

runnable = (
    {'prompt': RunnableLambda(find_matching_color)}
    | PromptTemplate.from_template('{prompt}')
    | model
)
runnable.invoke(['blue', 'purple', 'white'])

Prompting Utilities

join()

Formats a list of items as a natural language list.

Syntax:

join(items: Iterable, conjunction: str) -> str

pluralize()

Selects the singular or plural form of a word based on the number of items.

Syntax:

pluralize(singular: str, plural: str, items: Iterable) -> str

truncate()

Truncates a string to a maximum length. If the text is longer than the maximum length, all characters after the maximum length are replaced with the suffix.

Syntax:

truncate(
    text: str, max_length: int, mode=TruncateMode.CHARACTER, suffix="..."
) -> str

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

promptu-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptu-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file promptu-0.1.0.tar.gz.

File metadata

  • Download URL: promptu-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Darwin/23.3.0

File hashes

Hashes for promptu-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f62c5dc8fb7b10f173663488b1cbef4b2dd92a5d415c0c089456712acdd5f911
MD5 fad04b12ff22253b235c11edb346205c
BLAKE2b-256 0caca14166f66a0515275fbefcda9da9a0c2a48cddf84da5f89818c59c854698

See more details on using hashes here.

File details

Details for the file promptu-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: promptu-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Darwin/23.3.0

File hashes

Hashes for promptu-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45e34299077078f1c797090ebb2989b9b719c29f1574b9eb0e4b698a5e77261c
MD5 013f3f46ad51241fe2635b0b13b0e481
BLAKE2b-256 32d1fad4cd13b069e838c15c30db0e9768e7f9e382feb56191f510e4b47432d1

See more details on using hashes here.

Supported by

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