No project description provided
Project description
any-guardrail provides a unified interface for AI safety guardrails, for example, letting you detect toxic content, jailbreak attempts, and other risks in LLM inputs and outputs. Switch between different guardrail providers, both encoder-based (discriminative) and decoder-based (generative) models like Llama Guard and ShieldGemma, without changing your code.
Some guardrails are extremely customizable, which any-guardrail fully exposes. See the complete list of supported providers and customization examples in our docs.
Why any-guardrail?
- Unified API: Switch between evergrowing list of guardrail providers
- Production-ready: Built for real-world LLM applications
- Flexible: Use encoder-based (fast) or decoder-based (customizable) models
Quickstart
Requirements
- Python 3.11 or newer
Installation
Install with pip:
pip install any-guardrail
Basic Usage
AnyGuardrail provides a seamless interface for interacting with the guardrail models. It allows you to see a list of all the supported guardrails, and to instantiate each supported guardrail. Here is a full example:
from any_guardrail import AnyGuardrail, GuardrailName, GuardrailOutput
# Initialize guardrail
guardrail = AnyGuardrail.create(GuardrailName.DEEPSET)
# Validate input before sending to your LLM
result: GuardrailOutput = guardrail.validate("How do I hack into a system?")
if not result.valid:
print(f"Blocked: {result.explanation}")
else:
# Safe to proceed with LLM call
response = your_llm(user_input)
Documentation
Full guides at docs link
Troubleshooting
Some of the models on HuggingFace require extra permissions to use. To do this, you'll need to create a HuggingFace profile and manually go through the permissions. Then, you'll need to download the HuggingFace Hub and login. One way to do this is:
pip install --upgrade huggingface_hub
hf auth login
More information can be found here: HuggingFace Hub
Contributing to any-guardrail
The guardrail space is ever growing. If there is a guardrail that you'd like us to support, please see our CONTRIBUTING.md for details.
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 any_guardrail-0.3.2.tar.gz.
File metadata
- Download URL: any_guardrail-0.3.2.tar.gz
- Upload date:
- Size: 165.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a4661a4c6b799e55112acd75476f9adac048a29089f998fb3d4290e500eaec
|
|
| MD5 |
9f1887bcecc85f543b3962968b7aa795
|
|
| BLAKE2b-256 |
ddd32a431f2bf24e25bac62706e6b68445bbacac2d940951b5c6675c190b7034
|
Provenance
The following attestation bundles were made for any_guardrail-0.3.2.tar.gz:
Publisher:
release.yaml on mozilla-ai/any-guardrail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
any_guardrail-0.3.2.tar.gz -
Subject digest:
31a4661a4c6b799e55112acd75476f9adac048a29089f998fb3d4290e500eaec - Sigstore transparency entry: 910959401
- Sigstore integration time:
-
Permalink:
mozilla-ai/any-guardrail@9f24b1f21d80fc81472d32b9322da641926dea87 -
Branch / Tag:
refs/tags/0.3.2 - Owner: https://github.com/mozilla-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9f24b1f21d80fc81472d32b9322da641926dea87 -
Trigger Event:
release
-
Statement type:
File details
Details for the file any_guardrail-0.3.2-py3-none-any.whl.
File metadata
- Download URL: any_guardrail-0.3.2-py3-none-any.whl
- Upload date:
- Size: 43.8 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 |
a44af0a7e6366526f48ed5502ad168880d09c77dda03b95a6ce4d2b603dd3cc4
|
|
| MD5 |
a87b15dd16f96290153b818ac1873a88
|
|
| BLAKE2b-256 |
ff3bde571a19e0c3c83572b7c50e17b570e2ba86f47c59354ae1353f654d0f7f
|
Provenance
The following attestation bundles were made for any_guardrail-0.3.2-py3-none-any.whl:
Publisher:
release.yaml on mozilla-ai/any-guardrail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
any_guardrail-0.3.2-py3-none-any.whl -
Subject digest:
a44af0a7e6366526f48ed5502ad168880d09c77dda03b95a6ce4d2b603dd3cc4 - Sigstore transparency entry: 910959430
- Sigstore integration time:
-
Permalink:
mozilla-ai/any-guardrail@9f24b1f21d80fc81472d32b9322da641926dea87 -
Branch / Tag:
refs/tags/0.3.2 - Owner: https://github.com/mozilla-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9f24b1f21d80fc81472d32b9322da641926dea87 -
Trigger Event:
release
-
Statement type: