Skip to main content

Prompty is a new asset class and format for LLM prompts that aims to provide observability, understandability, and portability for developers. It includes spec, tooling, and a runtime. This Prompty runtime supports Python

Project description

Prompty is an asset class and format for LLM prompts designed to enhance observability, understandability, and portability for developers. The primary goal is to accelerate the developer inner loop of prompt engineering and prompt source management in a cross-language and cross-platform implementation.

The file format has a supporting toolchain with a VS Code extension and runtimes in multiple programming languages to simplify and accelerate your AI application development.

The tooling comes together in three ways: the prompty file asset, the VS Code extension tool, and runtimes in multiple programming languges.

The Prompty File Format

Prompty is a language agnostic prompt asset for creating prompts and engineering the responses. Learn more about the format here.

Examples prompty file:

---
name: Basic Prompt
description: A basic prompt that uses the GPT-3 chat API to answer questions
authors:
  - sethjuarez
  - jietong
model:
  api: chat
  configuration:
    azure_deployment: gpt-35-turbo
sample:
  firstName: Jane
  lastName: Doe
  question: What is the meaning of life?
---
system:
You are an AI assistant who helps people find information.
As the assistant, you answer questions briefly, succinctly, 
and in a personable manner using markdown and even add some personal flair with appropriate emojis.

# Customer
You are helping {{firstName}} {{lastName}} to find answers to their questions.
Use their name to address them in your responses.

user:
{{question}}

The Prompty VS Code Extension

Run Prompty files directly in VS Code. This Visual Studio Code extension offers an intuitive prompt playground within VS Code to streamline the prompt engineering process. You can find the Prompty extension in the Visual Studio Code Marketplace.

Download the VS Code extension here.

Using this Prompty Runtime

The Python runtime is a simple way to run your prompts in Python. The runtime is available as a Python package and can be installed using pip.

pip install prompty

Simple usage example:

import prompty

# execute the prompt
response = prompty.execute("path/to/prompty/file")

print(response)

Using Tracing in Prompty

Prompty supports tracing to help you understand the execution of your prompts. The built-in tracing dumps the execution of the prompt to a file.

import prompty
from prompty.tracer import Trace, PromptyTracer

# add default tracer
Trace.add_tracerTrace.add_tracer("prompty", PromptyTracer("path/to/trace/dir"))

# execute the prompt
response = prompty.execute("path/to/prompty/file")

print(response)

You can also bring your own tracer by creating a Tracer class. Simple example:

import prompty
from prompty.tracer import Tracer

class MyTracer(Tracer):

    def start(self, name: str) -> None:
        print(f"Starting {name}")

    def add(self, key: str, value: Any) -> None:
        print(f"Adding {key} with value {value}")

    def end(self) -> None:
        print("Ending")

# add your tracer
Trace.add_tracer("my_tracer", MyTracer())

# execute the prompt
response = prompty.execute("path/to/prompty/file")

To define your own tracer, you can subclass the Tracer class and implement the start, add, and end methods and then add it to the Trace instance. You can add as many tracers as you like - the will all of them will be called in order.

CLI

The Prompty runtime also comes with a CLI tool that allows you to run prompts from the command line. The CLI tool is installed with the Python package.

prompty -s path/to/prompty/file

This will execute the prompt and print the response to the console. It also has default tracing enabled.

Contributing

We welcome contributions to the Prompty project! This community led project is open to all contributors. The project cvan be found on GitHub.

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

prompty-0.1.10.tar.gz (198.8 kB view details)

Uploaded Source

Built Distribution

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

prompty-0.1.10-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file prompty-0.1.10.tar.gz.

File metadata

  • Download URL: prompty-0.1.10.tar.gz
  • Upload date:
  • Size: 198.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.17.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for prompty-0.1.10.tar.gz
Algorithm Hash digest
SHA256 27c449e5b743ee51a759643081f6ef4dc91ed6a461400a6f368a58f6f5ba8832
MD5 66c718ceb18f894e4ff76cacd16f60e8
BLAKE2b-256 4874cc1f0d155e9053aa98a72d8d2f60a8e830c390d07219c0d69e49c1d6060f

See more details on using hashes here.

File details

Details for the file prompty-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: prompty-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.17.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for prompty-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7979cc80345bc3a871f421d42c95b0d6d07ba697fe91df93b50b316b23fea4c7
MD5 9d6d0333dc3b5e9e8c0cb11a42a47073
BLAKE2b-256 7c2dd66551bd344db321b773f8a71f212609a056f0041ba8618e4da3d4a16daf

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