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:
- AwsPIIScannerWallExecutor: This class uses AWS Comprehend to scan text for Personally Identifiable Information (PII).
- 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 theAwsPIIScanner
andAwsPIIScannerWallExecutor
classes.prompt_defender_aws_defences/wall/sagemaker_inference.py
: Contains theRemoteSagemakerCaller
andSagemakerWallExecutor
classes.prompt_defender_aws_defences/wall/shared.py
: Defines shared utilities such asMatchLevel
andmatch_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for prompt_defender_aws_defences-0.1.26.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c8d41aa5c923c47957dcb437bbbb9636767ad09801ab2cf6b8c61361475d78 |
|
MD5 | d2e2b57803235d93e5227f20c17b0368 |
|
BLAKE2b-256 | 75cfca609540814d94539a05f51ff0d1d0deb323c6779f1b3c15f9341d679027 |
Hashes for prompt_defender_aws_defences-0.1.26-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6edbbdbe732978439ba2e9bd04fe1ae6a0f87917fda599e73adc35aae585789b |
|
MD5 | 1a10491d9d0e01d62213c68d686fb81d |
|
BLAKE2b-256 | ed3aaaa25ead76e817fb6bee0e85d52471063f224fc9fa21e32a6486561e60bf |