Skip to main content

A simple yet powerful prompt templating engine

Project description

Promuet

PyPI - Version PyPI - Downloads PyPI - Python Version

A simple yet powerful prompt templating engine

Promuet is a simple Python library for designing complex chains of prompts using basic prompt templates. See below for an example.

Example Usage

At the core, Promuet is just

template = TemplateMatchItem(
    """
        Task {{task_number:int}}: {{task_title}}
        Description: {{task_description}}

        Verification: {{task_verification_items:list}}
    """
)
input_string = """
    Task 12: Clean the house
    Description:
    I need to clean the house to make it nice.

    The floors need to be cleaned, the rugs vacuumed, and the laundry folded.

    Verification:
    - Floors should have no dust
    - Rugs should be free of dirt
    - Laundry should be folded
"""
data = template.parse(input_string)
assert data['.str'].strip() == textwrap.dedent(input_string).strip()
data = extract_data_vars(data)
assert data == dict(
    task_number=12,
    task_title='Clean the house',
    task_description='I need to clean the house to make it nice.\n\nThe floors need to be cleaned, the rugs vacuumed, and the laundry folded.',
    task_verification_items=[
        'Floors should have no dust',
        'Rugs should be free of dirt',
        'Laundry should be folded',
    ],
)

Installation

pip install promuet

License

promuet is distributed under the terms of the MIT license.

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

promuet-0.3.1.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

promuet-0.3.1-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

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