from murnitur import Guard, GuardConfig
from murnitur.guard import Payload, RuleSet
# Define the payload
payload = Payload(input="Test input", output="This is a test output")
# Define the ruleset with the custom metric
ruleset = RuleSet(
rules=[
{
"metric": "custom",
"value": "length_check"
}
],
action={"type": "OVERRIDE", "fallback": "Custom metric condition met."}
)
# Register the custom metric
Guard.register_custom_metric('length_check', custom_metric_function)
# Define the config
config = GuardConfig()
# Use the shield function with the custom metric
response = Guard.shield(payload, [ruleset], config)
print(response)