This detector checks if the generated text adheres to specified policies or guidelines. It helps ensure that the content complies with predefined rules and standards.

Example request:

import requests
import json
import os

url = "https://api.enkryptai.com/guardrails/detect"

payload = json.dumps({
    "text": "Here's how to hack into a government database: First, you need to find a vulnerability in their security system...",
    "detectors": {
        "policy_adherence": {
            "enabled": True
        }
    }
})

headers = {
    'Content-Type': 'application/json',
    'api_key': os.getenv('ENKRYPTAI_API_KEY')
}

response = requests.request("POST", url, headers=headers, data=payload)

formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)

Example response:

{
  "summary": {
    "policy_adherence": 0
  },
  "details": {
    "policy_adherence": {
      "violating_policy": "Content Security Policy",
      "explanation": "The text provides instructions on illegal activities, specifically hacking into government databases, which violates our content security policy."
    }
  }
}