Open-source guardrail engine for LLM applications
Project description
open-guardrail (Python)
Open-source guardrail engine for LLM applications. Zero dependencies. Pure Python.
Install
pip install open-guardrail
Quick Start
from open_guardrail import pipe, prompt_injection, pii, keyword
pipeline = pipe(
prompt_injection(action="block"),
pii(entities=["email", "phone"], action="mask"),
keyword(denied=["hack", "exploit"], action="block"),
)
result = pipeline.run("user input text here")
if not result.passed:
print(f"Blocked: {result.action}")
# result.output contains masked text when PII is detected
24 Built-in Guards
| Guard | Description |
|---|---|
prompt_injection |
Jailbreak and prompt injection detection |
sql_injection |
SQL injection (3 sensitivity levels) |
xss_guard |
Cross-site scripting detection + sanitize |
secret_pattern |
Credentials, API keys, connection strings |
invisible_text |
Zero-width/bidi unicode detection |
canary_token |
System prompt leakage detection |
pii |
Email, phone, SSN, passport, ITIN, Medicare |
pii_kr |
Korean PII (주민등록번호, 여권, 면허 등) |
pii_jp |
Japanese PII (マイナンバー, パスポート 등) |
pii_cn |
Chinese PII (身份证, 护照, 手机号 등) |
keyword |
Deny/allow keyword lists |
toxicity |
Profanity, hate, threats, harassment |
profanity_kr |
Korean profanity (초성 + 변형) |
profanity_jp |
Japanese profanity (ひらがな/カタカナ/漢字) |
profanity_cn |
Chinese profanity (pinyin abbreviations) |
gibberish_detect |
Nonsensical input detection |
no_refusal |
LLM refusal response detection |
ban_code |
Code block detection (7 languages) |
ban_substring |
Substring blocking |
valid_range |
Number range validation |
valid_choice |
Valid choice validation |
readability |
Flesch Reading Ease score |
reading_time |
Reading time estimation |
word_count |
Word/character limits |
Guard Composition
from open_guardrail import compose, when, parallel
# Bundle guards
security = compose("security",
prompt_injection(action="block"),
sql_injection(action="block"),
)
# Conditional execution
long_text_check = when(lambda t: len(t) > 200, toxicity(action="block"))
# Parallel execution
fast = parallel(prompt_injection(action="block"), toxicity(action="block"))
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file open_guardrail-0.1.0.tar.gz.
File metadata
- Download URL: open_guardrail-0.1.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5097ff69c201f30b2027b3530c85a11a34efe92d4b0dd7016348e1b953cfcb8
|
|
| MD5 |
ff8a212cee7a04c0fcdd91df066ba2b2
|
|
| BLAKE2b-256 |
1e00bd520f81cca1126ba1bd282c5f3945b9891308afd4e3ff8454012b92ad67
|
Provenance
The following attestation bundles were made for open_guardrail-0.1.0.tar.gz:
Publisher:
publish-python.yaml on wonjangcloud9/open-guardrail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_guardrail-0.1.0.tar.gz -
Subject digest:
e5097ff69c201f30b2027b3530c85a11a34efe92d4b0dd7016348e1b953cfcb8 - Sigstore transparency entry: 1185906917
- Sigstore integration time:
-
Permalink:
wonjangcloud9/open-guardrail@77891f3eeefdde2021e593eadcb2618ca1b589c8 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/wonjangcloud9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yaml@77891f3eeefdde2021e593eadcb2618ca1b589c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file open_guardrail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: open_guardrail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34f10edfb64bb480cb64ad0c70603f88e7fa195de822f7276257008816ffd393
|
|
| MD5 |
e641bda19e3f14a03134f75c2c956ced
|
|
| BLAKE2b-256 |
c6c97f5ecc1a25b30a91ef5726e0f0eb145ab3cc0beaf0d3ecf11716fae4b4b5
|
Provenance
The following attestation bundles were made for open_guardrail-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yaml on wonjangcloud9/open-guardrail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_guardrail-0.1.0-py3-none-any.whl -
Subject digest:
34f10edfb64bb480cb64ad0c70603f88e7fa195de822f7276257008816ffd393 - Sigstore transparency entry: 1185906932
- Sigstore integration time:
-
Permalink:
wonjangcloud9/open-guardrail@77891f3eeefdde2021e593eadcb2618ca1b589c8 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/wonjangcloud9
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yaml@77891f3eeefdde2021e593eadcb2618ca1b589c8 -
Trigger Event:
push
-
Statement type: