Skip to main content

An easy-to-use library for creating and seinding prompts to LLMs.

Project description

ezprompt

An easy-to-use library for creating and sending prompts to various LLMs.

Features (Planned)

  • Simple prompt definition using Markdown and Jinja templating.
  • Automatic input validation against prompt templates.
  • Model selection from a wide range of providers.
  • Context length validation with suggestions for suitable models.
  • Cost estimation before sending prompts.
  • Up-to-date model information (context size, pricing).
  • Asynchronous support for concurrent prompt execution.

Installation

pip install ezprompt # Not yet available on PyPI

Basic Usage

import asyncio
from ezprompt import Prompt

async def main():
    # Define a prompt template (details TBD)
    prompt_template = """
    Translate the following text from {{ source_lang }} to {{ target_lang }}:

    {{ text }}
    """

    # Initialize the prompt
    my_prompt = Prompt(
        template=prompt_template,
        inputs={"source_lang": "English", "target_lang": "French", "text": "Hello, world!"},
        model="gpt-3.5-turbo"
    )

    # Check for potential issues and estimate cost
    issues, cost = await my_prompt.check()
    if issues:
        print(f"Issues found: {issues}")
    else:
        print(f"Estimated cost: ${cost:.6f}")

        # Send the prompt
        response = await my_prompt.send()
        print(f"Model response: {response}")

if __name__ == "__main__":
    # Required environment variables (e.g., OPENAI_API_KEY)
    # Set them according to the model provider you use.
    asyncio.run(main())

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under 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

ez_prompt-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

ez_prompt-0.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file ez_prompt-0.1.1.tar.gz.

File metadata

  • Download URL: ez_prompt-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/10

File hashes

Hashes for ez_prompt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 016db629e9a65901c7231381b13a513f74b3d8aef86d23cda9c8371f3215a410
MD5 be1e2197fc2075050be10df33b2436f4
BLAKE2b-256 71c5f395eb94a714cbe3c599a22c69adb423c54c2eda490f1f65641142f8375a

See more details on using hashes here.

File details

Details for the file ez_prompt-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ez_prompt-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Windows/10

File hashes

Hashes for ez_prompt-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ac6b20613bb1a4b516a09f0e4a6dd1bd76b38057430bf89c42811a4284c3ea2
MD5 df21ff31d1f926308bc1e77a423c9cb0
BLAKE2b-256 a51ee500f1c2645fa54ecea8572e053aff657ae1da25eec836e30d7b690efa73

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