Skip to main content

Pytector

Pytector Logo

Build Tests Python Version 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

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

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.

Release files for pytector 0.0.9

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

Source distribution (sdist)

Source distribution for pytector 0.0.9
File Size Uploaded
pytector-0.0.9.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytector 0.0.9
File Interpreter ABI Platform
pytector-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / pytector-0.0.9.tar.gz

Download URL pytector-0.0.9.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e81a9f8dfc64ac7ade0570c91e24f903b3a1a26fa066c13fcef27f2b39cb1633
BLAKE2b-256 checksum
How to use checksums
36f20b0f18480b177d5a72fd637f48b445a3b53bde2bf823485367b0522e8002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / pytector-0.0.9-py3-none-any.whl

Download URL pytector-0.0.9-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c90d99d10aa5fdea1196f107a337fe371c4ad11740d5c044321a2531c470a093
BLAKE2b-256 checksum
How to use checksums
f11eb0141e10ce0cb21ee6b2866031c76e8d4b700ff86d753980633bc49a0a8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.0.12

2 release files

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

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