Skip to main content

Prompt Defender. A package to help you defend against prompt injection attacks.

Project description

README

Prompt Defender AWS Defences Library

Welcome to the Prompt Defender AWS Defences library. This library is designed to help you defend against prompt injection attacks by leveraging AWS services such as AWS Comprehend and SageMaker. The library is written in Python and can be easily installed via pip.

Installation

You can install the library using pip:

pip install prompt-defender-aws-defences

Usage

This library provides two main classes to help in detecting and preventing prompt injection attacks:

  1. AwsPIIScannerWallExecutor: This class uses AWS Comprehend to scan text for Personally Identifiable Information (PII).
  2. SagemakerWallExecutor: This class calls a remote SageMaker endpoint to validate the prompt.

Example

You can find example usage in the example.py file.

from prompt_defender_aws_defences import AwsPIIScannerWallExecutor, SagemakerWallExecutor

# Example usage of AwsPIIScannerWallExecutor
pii_executor = AwsPIIScannerWallExecutor()
validation_result = pii_executor.is_user_input_safe("Your text to scan here")
print(validation_result)

# Example usage of SagemakerWallExecutor
sagemaker_executor = SagemakerWallExecutor(sagemaker_name="your-sagemaker-endpoint")
validation_result = sagemaker_executor.is_user_input_safe("Your text to validate here")
print(validation_result)

Directory Structure

The main class files are located in the prompt_defender_aws_defences directory:

  • prompt_defender_aws_defences/__init__.py: Initializes the package and imports the main executors.
  • prompt_defender_aws_defences/wall/pii_detection.py: Contains the AwsPIIScanner and AwsPIIScannerWallExecutor classes.
  • prompt_defender_aws_defences/wall/sagemaker_inference.py: Contains the RemoteSagemakerCaller and SagemakerWallExecutor classes.
  • prompt_defender_aws_defences/wall/shared.py: Defines shared utilities such as MatchLevel and match_level_for_score.
  • prompt_defender_aws_defences/wall/__init__.py: Initializes the wall module and imports the necessary executors.

License

This project is licensed under the Apache License. See the LICENSE file for more details.

Contact

For any questions or issues, please contact the project owner at admin@safetorun.com.

Contributing

Contributions are welcome! Please refer to the project's GitHub Issues page for any open issues or feature requests.

Additional Information

For more details, please visit the project's Homepage.

We hope you find this library useful in defending against prompt injection attacks!


Happy coding! 🛡️

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

prompt_defender_aws_defences-0.1.26.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

prompt_defender_aws_defences-0.1.26-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file prompt_defender_aws_defences-0.1.26.tar.gz.

File metadata

File hashes

Hashes for prompt_defender_aws_defences-0.1.26.tar.gz
Algorithm Hash digest
SHA256 83c8d41aa5c923c47957dcb437bbbb9636767ad09801ab2cf6b8c61361475d78
MD5 d2e2b57803235d93e5227f20c17b0368
BLAKE2b-256 75cfca609540814d94539a05f51ff0d1d0deb323c6779f1b3c15f9341d679027

See more details on using hashes here.

File details

Details for the file prompt_defender_aws_defences-0.1.26-py3-none-any.whl.

File metadata

File hashes

Hashes for prompt_defender_aws_defences-0.1.26-py3-none-any.whl
Algorithm Hash digest
SHA256 6edbbdbe732978439ba2e9bd04fe1ae6a0f87917fda599e73adc35aae585789b
MD5 1a10491d9d0e01d62213c68d686fb81d
BLAKE2b-256 ed3aaaa25ead76e817fb6bee0e85d52471063f224fc9fa21e32a6486561e60bf

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