Skip to main content

Prompt-Horizon

Prompt-Horizon is a Python library that enables developers to anonymize JSON objects by creating placeholders for keys and values, while generating a reversible mapping to restore the original JSON data. The purpose of this library is to facilitate data sharing while preserving privacy and allowing for the de-anonymization of the data when required.

Note: I had the idea for this library when I was trying to find a way to obfuscate data objects such as JSON to include them as contextual information in prompts (hence the name).

Prompt-Horizon is not designed to specifically identify and anonymize PII (personally identifiable information) or other sensitive data within the JSON objects.


Installation

pip install prompt-horizon

Usage

Anonymize JSON


from prompt_horizon import anonymize

input_json = {
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}

#This line will return the anonymized JSON object and the mapping object.
anonymized_json, map_object = anonymize(input_json)

Original JSON:

{
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}

Anonymized JSON:

{
    "a1": "a2",
    "a3": "a4",
    "a5": "a6",
    "a7": ["a8", "a9"]
}

input and output file handling is supported

from prompt_horizon import anonymize

#This line will read the JSON data from "input.json", anonymize it, and save the anonymized JSON to "anonymized.json".
anonymized_json, map_object = anonymize("input.json", output_file_path="anonymized.json")

anonymize only the values

from prompt_horizon import anonymize

#This line will read the JSON data from "input.json" and anonymize only the values.
anonymized_json, map_object = anonymize("input.json", anonymize_keys=False)

De-anonymize JSON


from prompt_horizon import de_anonymize

#This line will return the de-anonymized JSON object, which should be the same as the original input JSON.
deanonymized_json = de_anonymize(anonymized_json, map_object=map_object)

input and output files are supported

from prompt_horizon import de_anonymize

#This will read the anonymized JSON data from "anonymized.json", the mapping object from "map_file.json", de-anonymize the JSON data, and save the de-anonymized JSON to "deanonymized.json".
deanonymized_json = de_anonymize("anonymized.json", map_file_path="map_file.json", output_file_path="deanonymized.json")

License

This project is licensed under the MIT License.

Metadata

Release files for prompt-horizon 0.1.4

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

Source distribution (sdist)

Source distribution for prompt-horizon 0.1.4
File Size Uploaded
prompt-horizon-0.1.4.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prompt-horizon 0.1.4
File Interpreter ABI Platform
prompt_horizon-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.4 kB

Release files / prompt-horizon-0.1.4.tar.gz

Download URL prompt-horizon-0.1.4.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dd70a01e4aedcd7b68d117ccdea3218566320f2f57093ab10952cd149c0e300
BLAKE2b-256 checksum
How to use checksums
497742d1be812fb6756e3fa9f517b4ec9fb8e0741e15773b0edf7361538f7915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / prompt_horizon-0.1.4-py3-none-any.whl

Download URL prompt_horizon-0.1.4-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
859cf37a3ded5f1e5777c40431419600065548c0a0b2ac3febf61c8846e0b1f6
BLAKE2b-256 checksum
How to use checksums
530e7f5d7fd07a0e25e537fe14ed207220018520c9dc79758f07338fce3607f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

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