Quick Start
Requirements
Python 3.11 or newer
Installation
You can install the bare bones library as follows (only [any_guardrails.guardrails.any_llm.AnyLlm] will be available):
pip install any-guardrailOr you can install it with the required dependencies for different guardrails:
pip install any-guardrail[huggingface]Refer to pyproject.toml for a list of the options available.
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 guardrails. Here is a full example:
from any_guardrail import AnyGuardrail, GuardrailName, GuardrailOutput
guardrail = AnyGuardrail.create(GuardrailName.DEEPSET)
result: GuardrailOutput = guardrail.validate("All smiles from me!")
assert result.validDiscovering guardrails
Every guardrail carries static, queryable metadata (what it detects, where it runs, how it executes) that you can filter and group without importing any model backend — handy for building your own catalog or picking a guardrail programmatically:
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:
More information can be found here: HuggingFace Hub
Last updated