Protect
How to
Step 1 : Setting API key
Set up your Future AGI account and get started with the Future AGI Python client, follow steps here: https://docs.futureagi.com/future-agi/products/evaluations/quickstart
Step 2 : Installation and Setup
Step 3 : Setting up Protect Metrics
The protect class contains several arguments, these are listed as follows :
Argument | Type | Default Value | Significance |
---|---|---|---|
input | string | - | The input string that will be checked against the rules |
protect_rules | List[Dict] | - | Specifies the evaluation rules to apply to the input string |
action | string | Response cannot be generated as the input fails the checks | Specifies the message to return when a rule check fails |
reason | bool | False | Determines whether to include the failure reason in the output |
timeout | integer | 30 | Maximum time in seconds allowed for rule checking |
Defining Rules :
We define rules as a list of custom Protect metrics. Each Protect metric is a dictionary with some fixed keys.
Each Protect Metric is made up of different parameters as defined below :
Key | Requirement | Input Type | Possible Values | Default Value | Function |
---|---|---|---|---|---|
metric | Required | string | Toxicity, Tone, Sexism, Prompt Injection, Data Privacy | — | Defines the evaluation metric to be used |
contains | Required for Tone only | list[string] | For Tone: neutral, joy, love, fear, surprise, sadness, anger, annoyance, confusion | — | Checks if specified values are present in evaluation response |
type | Required for Tone only | string | For Tone: any / all | any | Determines if rule passes when any or all contained values are present |
Example:
You can define multiple rules. The evaluation stops as soon as 1 rule fails.
Understanding the Outputs
The returned output is in form of a dictionary with different keys, each of which convey various details related to performance of the input query when passed through the defined protection evaluations.
Key | Possible Values | Significance |
---|---|---|
status | passed / failed | Indicates if the input passed all protection rules. For timeouts, status reflects results of completed checks only. |
messages | string | Shows the action message if status is “Failed”; otherwise displays the original input text. |
completed_rules | list of completed rule checks | Lists all metrics evaluated within the timeout period. |
uncompleted_rules | list of uncompleted rule checks | Lists metrics not evaluated due to earlier failure or timeout. |
failed_rule | string | Names the rule check that failed. Returns None if all checks pass. |
reason | string | Provides explanation for why the input failed the rule checks. |
time_taken | integer | Total duration of protection evaluation process. |