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):
Or you can install it with the required dependencies for different guardrails:
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.valid
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