Invoke rulesets in Galileo Protect to apply AI safeguards effectively, with comprehensive guidance on ruleset usage, configuration, and execution.
You’ll need to invoke Protect whenever there’s an input or output you want to validate.
You might choose to run multiple validations on different stages of your workflow (e.g. once when you get the query from your user, another time once the model has generated a response for the given task).
At invocation time, you can either pass the project ID and stage name or the stage ID directly. These can be set as environment variables or passed directly to the invoke method as below.
response = gp.invoke( payload=gp.Payload(output="here is my SSN 123-45-6789"), prioritized_rulesets=[ gp.Ruleset( rules=[ gp.Rule( metric=gp.RuleMetrics.pii, operator=gp.RuleOperator.contains, target_value="ssn", ) ], action=gp.OverrideAction( choices=["Sorry, I cannot answer that question."] ), ) ], stage_id=stage_id,)response.text
At invocation time, you can either pass the project ID and stage name or the stage ID directly. These can be set as environment variables or passed directly to the invoke method as below.
response = gp.invoke( payload=gp.Payload(output="here is my SSN 123-45-6789"), prioritized_rulesets=[ gp.Ruleset( rules=[ gp.Rule( metric=gp.RuleMetrics.pii, operator=gp.RuleOperator.contains, target_value="ssn", ) ], action=gp.OverrideAction( choices=["Sorry, I cannot answer that question."] ), ) ], stage_id=stage_id,)response.text
To invoke Protect using the REST API, simply make a POST request to the /v1/protect/invoke endpoint with your Rules and Actions.
If the project or stage name don’t exist, a project + stage will be created for you for convenience.