Skip to main content

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

Project description

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.

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.10.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

pytector-0.0.10-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pytector-0.0.10.tar.gz.

File metadata

  • Download URL: pytector-0.0.10.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pytector-0.0.10.tar.gz
Algorithm Hash digest
SHA256 fa068fbfdcb5dd9bb9a61920e20d59c37111c79ca0fae99875ad200b09470c41
MD5 2e8f5dc0816e357edd59a9d6c0732aa0
BLAKE2b-256 473212d3a267d017372f0599857909101d28a1817f24b8062167c2c51c3c6027

See more details on using hashes here.

File details

Details for the file pytector-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pytector-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pytector-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0fcfb937f15203e17b015a8d61b21acd8a8ef8be81f793b2b39653a5bb5e40c5
MD5 63a12420c12558357ece942594bb8878
BLAKE2b-256 22e092f346a0598916e309b9916890159f10b8049fff10058419ca1f527637b7

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