Guardrails
Guardrails are configurable sets of rules and filters designed to enforce content safety, compliance, and quality standards within your data workflows. By defining guardrails, you can automatically detect and block sensitive information, filter out inappropriate language, prevent prompt attacks, and restrict certain topics or behaviors. Guardrails help ensure that your data and AI applications operate within organizational and regulatory boundaries.
Below is the sample resource definition file for Guardrail:
{
"rGuardrail": {
"Type": "Guardrail",
"Properties": {
"GuardRailName": "MyGuardrail",
"Description": "Example guardrail for content filtering and safety",
"IsCrossRegionEnabled": true,
"Tier": "STANDARD",
"Scope": "global",
"BlockedMessage": "This content has been blocked by the guardrail",
"GroundingThreshold": 0.8,
"RelevanceThreshold": 0.7,
"EnableContextualGroundingCheck": true,
"SensitiveInformationFilters": {
"PiiTypesToFilter": [
{
"Type": "EMAIL",
"Action": "BLOCK"
},
{
"Type": "PHONE",
"Action": "ANONYMIZE"
}
],
"CustomRegexFilters": [
{
"RegexName": "CreditCardPattern",
"Pattern": "\\d{4}-\\d{4}-\\d{4}-\\d{4}",
"Action": "BLOCK"
}
]
},
"CustomWordFilters": {
"BlockWords": ["inappropriate", "spam"],
"EnableProfanityFilter": true
},
"FiltersConfig": [
{
"Type": "PROMPT_ATTACK",
"InputStrength": "NONE",
"OutputStrength": "NONE"
}
],
"DeniedTopics": [
{
"TopicName": "Politics",
"TopicDefinition": "Content related to politics",
"ExamplePhrases": ["how to hurt someone", "politics"]
}
]
}
}
}
Guardrails require an additional Services key. You must provide at least one service in Services.
Supported service values:
knowledgebasesagentsjobsdatalabsnl2sqldata-pipelinesdatasetschats
Guardrail has dependencies on Tag.
Dependent resources should not be deleted before the primary resource; attempting to do so may lead to failures or inconsistencies during the deletion process.
Referencing this Resource
Below are the common keys that can be used in the DependsOn function to retrieve details of this resource.
Supported Keys
| Key | Description |
|---|---|
| GuardRailId | Returns the GuardRailId value of this resource |
| GuardRailName | Returns the GuardRailName value of this resource |
For additional supported keys, refer to the API definition document for the respective resource type.
Example
The following example shows how to retrieve the guardrail ID from a guardrail template and use it in an agent template:
{
"rAgent": {
"Type": "Agent",
"Properties": {
"ResourceAccessMetadata": {
"GuardRails": [
{
"Id": {
"!DependsOn": "rGuardrail.GuardRailId"
}
}
]
}
}
}
}