Keeping your prompts clean since 2023
Project description
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
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
prettyprompt-0.1.5.tar.gz
(7.9 kB
view details)
Built Distribution
File details
Details for the file prettyprompt-0.1.5.tar.gz
.
File metadata
- Download URL: prettyprompt-0.1.5.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48ba2de04668da3efd82e5829316d58b9b01582bfdbdf978eae5ce77f98915cb |
|
MD5 | a1649d785d0baeda3accf877f4c2d916 |
|
BLAKE2b-256 | a1e7fc5148abad84d01d107cb2b357919c9cb665fdca2eb56277d88242ef18b5 |
Provenance
File details
Details for the file prettyprompt-0.1.5-py2.py3-none-any.whl
.
File metadata
- Download URL: prettyprompt-0.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c45b0f3fda6bb52aa1fc718bf3c160dae732bb00eb907ff0be3f985d512aa3c4 |
|
MD5 | 31c0a162b2239bf214224a1835a09f3c |
|
BLAKE2b-256 | 0b081db8b2796ecbbacb50ac136bfc6a8ea4e69832721322cd7cf76af32f907b |