Skip to content

hillstoneLeo/grails

Repository files navigation

HillStone Guardrails POC

Usage

In virtualenv:

In Container:

Development

uv init --name grails --python 3.12 --vcs git --app
uv add guardrails-ai ipython
uv run guardrails configure
uv run guardrails hub install hub://guardrails/regex_match
uv run guardrails hub install hub://guardrails/valid_json
uv run guardrails hub install hub://guardrails/valid_length

uv run guardrails hub create-validator sensitive_words  # edit the script
uv run guardrails hub submit sensitive_words

Demo Codes

from guardrails import Guard
from guardrails.hub import RegexMatch, ValidLength, ValidJson

def fail_msg(msg, fail_result):
    return f"{len(msg)}\n{fail_result.outcome}\n{fail_result.error_message}"

guard = Guard().use_many(
        RegexMatch(regex=".*Security.*",
                   on_fail=fail_msg),
        ValidLength(min=10, max=500, on_fail=fail_msg),
        ValidJson(on_fail=fail_msg))

About

Guardrails demo for LLM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published