Skip to main content

A package for loading promptdown files, which are a special type of markdown file for defining structured LLM prompts

Project description

Promptdown

Promptdown is a Python package that allows you to express structured prompts for language models in a markdown format. It provides a simple and intuitive way to define and manage prompts, making it easier to work with language models in your projects.

Installation

Using PDM

Promptdown can be installed using PDM:

pdm add promptdown

Using pip

Alternatively, you can install Promptdown using pip:

pip install promptdown

Usage

Basic Usage

To use Promptdown, simply create a Promptdown file (.prompt.md) with the following format:

# My Prompt

## System Message

You are a helpful assistant.

## Conversation

| Role      | Content                                     |
|-----------|---------------------------------------------|
| User      | Hi, can you help me?                        |
| Assistant | Of course! What do you need assistance with?|
| User      | I'm having trouble with my code.            |
| Assistant | I'd be happy to help. What seems to be the problem? |

Then, you can parse this file into a StructuredPrompt object using Promptdown:

from promptdown import StructuredPrompt

structured_prompt = StructuredPrompt.from_promptdown_file('path/to/my_prompt.prompt.md')
print(structured_prompt)

Advanced Usage

You can also parse a Promptdown string directly:

promptdown_string = """
# My Prompt

## System Message

You are a helpful assistant.

## Conversation

| Role      | Content                                     |
|-----------|---------------------------------------------|
| User      | Hi, can you help me?                        |
| Assistant | Of course! What do you need assistance with?|
| User      | I'm having trouble with my code.            |
| Assistant | I'd be happy to help. What seems to be the problem? |
"""

structured_prompt = StructuredPrompt.from_promptdown_string(promptdown_string)
print(structured_prompt)

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

Promptdown is released 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

promptdown-0.2.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

promptdown-0.2.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file promptdown-0.2.1.tar.gz.

File metadata

  • Download URL: promptdown-0.2.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for promptdown-0.2.1.tar.gz
Algorithm Hash digest
SHA256 83b87d0924066fb9f74f66e1192b5a4b8da8a7f27b79455909d4d3cd53031397
MD5 dd32f982f3b5c5438719bf71468ee770
BLAKE2b-256 a638ff00deaf69be5f104c7889bdd27acb2b85e5b11a872f1498bfca5a43d2f5

See more details on using hashes here.

File details

Details for the file promptdown-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: promptdown-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for promptdown-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ca8fa930fbbccbb9f65cf990b80cdd0015559aef8462088a46f7fac13cca772
MD5 a8fd4629b63eb9078f8bb2bd28219938
BLAKE2b-256 aa8c03f3eac5f0996d317aa5299705be64f078d79be0ea75f2688d36e6b8ed10

See more details on using hashes here.

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