pretty_prompt_compare
A python package for comparing prompts/responses with pretty print.
https://github.com/user-attachments/assets/ef152000-a954-4e3e-ad05-47f840d0db09
In the age of LLMs, a lot of prompt engineering comes down to comparing prompts and their responses. This Python package helps by pretty-printing pairs of prompts and responses, making it easier to see differences and embed this workflow into your Python development environment.
Installation
pip install pretty_prompt_compare
Usage
-
To compare prompts, use the
compare_prompt=Trueargument. The prompt will be printed in the console with differences highlighted, and f-string expressions shown in a different color.from pretty_prompt_compare import PrettyCompare # to compare differences in prompts pretty_compare = PrettyCompare(compare_prompt=True) "Hello beautiful {world}" |pretty_compare| "Hello brave {world}"
The two prompts on either side of the
|pretty_compare|operation will be printed using the following format:- {first prompt} + {second prompt}
If
print_separator=True, a separator line will be printed between the two prompts.In the printed second prompt:
- Characters that appear only in the first prompt will be highlighted using
COLOR_PALETTE["delete"]and shown with astrikethrough. - Characters that appear only in the second prompt will be highlighted using
COLOR_PALETTE["insert"].
In both prompts, the
{f-string expressions}will be highlighted in value ofCOLOR_PALETTE["f-string expression"]. - Characters that appear only in the first prompt will be highlighted using
-
To compare responses, use the
compare_response=Trueargument. The responses will be printed in the console with differences highlighted, and target strings highlighted in a different color.from pretty_prompt_compare import PrettyCompare # to compare differences in responses pretty_compare = PrettyCompare(compare_response=True, target=["brave", "beautiful", "world"]) "Hello beautiful {world}" |pretty_compare| "Hello brave {world}"
The responses are displayed in a similar format to the prompts, with the additional feature that target strings are highlighted using
COLOR_PALETTE["focus"]with underline and bold. -
To Change the color palette, use the
color_paletteargument.# compare differences in prompts with custom color palette pretty_compare = PrettyCompare(compare_prompt=True, color_palette=...)
The default color palette can be found at https://github.com/com3dian/pretty_prompt_compare/blob/7cbad091065d0b962fb7288b090333bc95ede305/src/pretty_prompt_compare.py#L34-L40
Note
The prompts/responses are compared using the difflib.SequenceMatcher class. The algorithm for text comparison is based on the Ratcliff/Obershelp pattern recognition algorithm. For more reference please visit https://docs.python.org/3/library/difflib.html#difflib.SequenceMatcher.
License
MIT License
Metadata
Release files for pretty-prompt-compare 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pretty_prompt_compare-0.0.2.tar.gz | 35.0 kB | Without provenance | Details for pretty_prompt_compare-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pretty_prompt_compare-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pretty_prompt_compare-0.0.2-py3-none-any.whl |
Total release size: 41.9 kB
Release files / pretty_prompt_compare-0.0.2.tar.gz
| Download URL | pretty_prompt_compare-0.0.2.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
002db12d187138e4d124c2fe9dded8fb5e180591f0838687e629b8176065fc89
|
|
BLAKE2b-256 checksum How to use checksums |
8f224ad1cfdf21cb32dded81d10f383b53d95a575440fee8d9f7ca031b9e90a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / pretty_prompt_compare-0.0.2-py3-none-any.whl
| Download URL | pretty_prompt_compare-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
541994a55850eb406e45ae5ea05c9d4b24b04ac5f19e6a6a14fb0c2b9fafeab1
|
|
BLAKE2b-256 checksum How to use checksums |
d903c2964dbf2dc984f04623dce41faa79ed4e1902008ceceaeb7489523f811a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for pretty-prompt-compare 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.