Skip to main content

Pretty Prompt

Simple tools for better prompts.

Installation

pip install prettyprompt

Usage

Sniffing bad intentions

from prettyprompt import sniffers

# will this SQL statement write to my database?
sniffers.is_sql_write_statement(user_supplied_sql)

# is this a prompt injection attempt? ask ChatGPT
# (needs an OpenAI API key)
sniffers.is_prompt_injection(prompt, strategy="LLM")

# uses spaCy to indicate the imperative-ness of a string
# needs a trained pipeline e.g. `python -m spacy download en_core_web_sm`
sniffers.is_imperative(prompt)

Converting input

from prettyprompt import converters

# convert scraped HTML into plain text, maintaining some structure
converters.html_to_text(scraped_html)

# splits text into meaningful chunks, using GPT-3.5
converters.chunker(long_text, max_words_per_chunk, min_words_per_chunk)

Cleaning input

from prettyprompt import cleaners

# remove tags from HTML
cleaners.remove_tags(html)

# normalise spaces
cleaners.normalise_spaces(text)

# swap common 'smart' characters with ASCII equivalents
cleaners.simplify_text(text)

Tests

  • pip install pytest pytest-mock
  • pytest

TODO

Release files for prettyprompt 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prettyprompt 0.1.5
File Size Uploaded
prettyprompt-0.1.5.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prettyprompt 0.1.5
File Interpreter ABI Platform
prettyprompt-0.1.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 13.0 kB

Release files / prettyprompt-0.1.5.tar.gz

Download URL prettyprompt-0.1.5.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
48ba2de04668da3efd82e5829316d58b9b01582bfdbdf978eae5ce77f98915cb
BLAKE2b-256 checksum
How to use checksums
a1e7fc5148abad84d01d107cb2b357919c9cb665fdca2eb56277d88242ef18b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.2

Release files / prettyprompt-0.1.5-py2.py3-none-any.whl

Download URL prettyprompt-0.1.5-py2.py3-none-any.whl
Size 5.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c45b0f3fda6bb52aa1fc718bf3c160dae732bb00eb907ff0be3f985d512aa3c4
BLAKE2b-256 checksum
How to use checksums
0b081db8b2796ecbbacb50ac136bfc6a8ea4e69832721322cd7cf76af32f907b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.2

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page