Skip to main content

A package for detecting prompt injections in text using Open-Source LLMs.

Project description

Pytector

Workflow Status Python Version License Issues Pull Requests Pytector is a Python package designed to detect prompt injection in text inputs using state-of-the-art machine learning models from the transformers library.

Disclaimer

The Pytector package is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. Pytector is still a prototype and cannot provide 100% protection against prompt injection attacks!

Features

  • Detect prompt injections with pre-trained models.
  • Support for multiple models including DeBERTa, DistilBERT, and ONNX versions.
  • Easy-to-use interface with customizable threshold settings.

Installation

Via PIP

pip install pytector

Install Pytector directly from the source code:

git clone https://github.com/MaxMLang/pytector.git
cd pytector
pip install .

Usage

To use Pytector, you can import the PromptInjectionDetector class and create an instance with a pre-defined model or a custom model URL.

import pytector

# Initialize the detector with a pre-defined model
detector = pytector.PromptInjectionDetector(model_name_or_url="deberta")

# Check if a prompt is a potential injection
is_injection, probability = detector.detect_injection("Your suspicious prompt here")
print(f"Is injection: {is_injection}, Probability: {probability}")

Documentation

For full documentation, visit the docs directory.

Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

pytector-0.0.7.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

pytector-0.0.7-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page