/internal_domains

Primary LanguagePythonApache License 2.0Apache-2.0

Overview

Developed by David Tam
Date of development Aug 13, 2024
Validator type Format
License Apache 2
Input/Output Output

Description

Identifies internal domains in a string output.

(Optional) Intended Use

finds internal domains in a string output like "internal.example.com" or "example.internal".

Requirements

  • Dependencies:

    • guardrails-ai>=0.4.0
  • Dev Dependencies:

    • pytest
    • pyright
    • ruff

Installation

$ guardrails hub install hub://guardrails/internal_domains

Usage Examples

Validating string output via Python

In this example, we apply the validator to a string output generated by an LLM.

# Import Guard and Validator
from guardrails.hub import InternalDomains
from guardrails import Guard

# Setup Guard
guard = Guard.use(
    InternalDomains(internal_domains= ["internal.example.com"]),
)

guard.validate("This is a string with no domains except a reference to https://www.example.com")  # Validator passes
guard.validate("This string includes a link to https://internal.example.com/wiki/welcome-guide")  # Validator fails