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.0.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.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ez_prompt-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e3d1901d66451fd2a8412805d811f0130bf5682d6c699b114abd1d09bccc4e18
MD5 2a372e41a91d70dd11880ae3337ac873
BLAKE2b-256 20ae0b8cc13b6b39dead8d297fce95dc6c22b2d63835d0d3a8f3e2bc522ccde0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ez_prompt-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ed6211eddebd2a49bf76feb731e12b2c2e55647f8c8f43e3cd87c61545df619
MD5 3fb31e9decffda78c4dbe88b72220b33
BLAKE2b-256 06b8f9607af2b4a0b521f7b37b65bf59dd1cdfa4ef0587e62de9c7c21e6e3720

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