Actions are user-defined actions that are taken as a result of the ruleset being triggered.

An Action can be defined as:

gp.OverrideAction(
    choices=["Sorry, I cannot answer that question."]
)

The action would be included in the ruleset definition as:

gp.Ruleset(
    rules=[
        gp.Rule(
            metric=gp.RuleMetrics.pii,
            operator=gp.RuleOperator.contains,
            target_value="ssn"
        ),
        gp.Rule(
            metric=gp.RuleMetrics.toxicity,
            operator=gp.RuleOperator.gt,
            target_value=0.8
        )
    ],
    action=gp.OverrideAction(
        choices=["Sorry, I cannot answer that question."]
    )
)

Was this page helpful?