Skip to main content

Python client for PromptFold API - optimize prompts with PromptFold

Project description

PromptFold Client Library

This package provides a simple Python client for the PromptFold API available on PyPI.

Installation

pip install promptfold

Usage

import openai
from promptfold_client import PromptFold

# Initialize PromptFold client, compress your system prompt
pf_client = PromptFold(api_key="YOUR_PROMPTFOLD_API_KEY", system_prompt="Your system prompt.")

# Compress the original user prompt and system prompt
compressed = pf_client.compress_prompt(user_prompt="Input user prompt")

# Call OpenAI's GPT-4 with the compressed prompt
openai.api_key = "YOUR_OPENAI_API_KEY"
response = openai.ChatCompletion.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": compressed.compressed_system_prompt},
        {"role": "user", "content": compressed.compressed_user_prompt}
    ]
)

# Print the response from GPT-4
print(response["choices"][0]["message"]["content"])

Publishing a New Version (for Maintainers)

Publishing the client is handled by a script that automates the entire process.

Prerequisites:

  1. PyPI Account: You need an account on PyPI and an API token.
  2. Twine Configuration: Your local machine must be configured to authenticate with PyPI. You can do this by setting the TWINE_USERNAME and TWINE_PASSWORD environment variables.

To publish a new version:

  1. Navigate to the client directory: cd promptfold_client
  2. Run the publishing script. You have two options:
    • To automatically bump the patch version (e.g., 1.0.1 -> 1.0.2), run the script without arguments:
      ./publish_pypi.sh
      
    • To specify an exact version (e.g., for a major release like 2.0.0), provide it as an argument:
      ./publish_pypi.sh 2.0.0
      
  3. The script will handle everything else automatically.

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

promptfold-1.0.7.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

promptfold-1.0.7-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file promptfold-1.0.7.tar.gz.

File metadata

  • Download URL: promptfold-1.0.7.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for promptfold-1.0.7.tar.gz
Algorithm Hash digest
SHA256 87105f222a58d6d1946c6d8ec15d47f84213374b670506625a716905922210ef
MD5 42f9237fdb1f421ac8da12c612a535f9
BLAKE2b-256 3685320b7313cebb4ada0b3e771ddcaa4f9424e04f00b829aaf194c1d110a0ee

See more details on using hashes here.

File details

Details for the file promptfold-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: promptfold-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for promptfold-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7b01b81f6624c84e44d8b52673715ae3a0c42a367d0f79592d5ebbf0898f89e0
MD5 b3bb9a81878cbf240da0b56677525359
BLAKE2b-256 eb96706525e42c17393220681abfe8e689a0d56ed7294c5abe2c493ea66b95cb

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