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 ez-prompt

Basic Usage

See the supported models by running:

from ez_prompt import list_models

list_models()

Then, create a template, choose your model, provide an API key, format and send. Sending is asynchronous by default.

import asyncio
from ez_prompt 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,
        model="gpt-3.5-turbo",
        api_key="your_api_key"
    )

    # Format the prompt with inputs
    my_prompt.format(
        inputs={"source_lang": "English", "target_lang": "French", "text": "Hello, world!"},
    )

    # 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.3.tar.gz (9.2 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.3-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ez_prompt-0.1.3.tar.gz
  • Upload date:
  • Size: 9.2 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.3.tar.gz
Algorithm Hash digest
SHA256 7bdf49b4d77cfb6bcc81a0f8a4f630b2cc7f1c4e7cde001ea7fd0bb5958e78c3
MD5 45674dfe45a43e598c86563c06b77bee
BLAKE2b-256 b87f7e6df9afe0383852c6f112535bee93748194b81c11618ae1d5618d70eb14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ez_prompt-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 901ffcfe956dd0e9afdd89e4d1bb01b02c140cb641a9a76be1f0296537d55362
MD5 6fc8778e077fdf039170828657c15a70
BLAKE2b-256 cf6f7b437ea1031043a4e3d5a180bda7f8fd00a0074b20ac26dc987dd1cc05c7

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