Feature
Define governance rules in human-readable YAML and enforce them consistently across all your AI operations. Block, warn, redact, or allow based on content, user context, or custom conditions.
Tork's Policy Engine evaluates every AI input and output against your defined rules before they're processed or returned. This happens in milliseconds, adding negligible latency while providing complete governance control.
policy.yaml
policies:
# Block harmful content
- name: content-safety
trigger: output
action: BLOCK
conditions:
- type: contains_harmful_content
threshold: 0.8
message: "Content blocked due to safety policy"
# Redact PII before sending to AI
- name: pii-protection
trigger: input
action: REDACT
patterns:
- email
- phone
- ssn
- credit_card
# Warn on sensitive topics
- name: sensitive-topics
trigger: output
action: WARN
keywords:
- medical_advice
- legal_advice
- financial_advice
escalate_to: compliance@company.comLet the content pass through unchanged. Use for approved patterns or trusted sources.
Reject the request entirely. Returns a configurable error message to the user.
Remove or mask sensitive content while allowing the request to proceed.
Allow but flag for review. Optionally notify compliance teams via webhook.
Python
from tork import PolicyEngine
# Load your policies
engine = PolicyEngine.from_yaml("policy.yaml")
# Evaluate input before sending to AI
user_input = "Contact me at john@example.com"
input_result = engine.evaluate(user_input, trigger="input")
if input_result.action == "BLOCK":
return {"error": input_result.message}
# Safe input - proceed with AI call
ai_response = call_your_ai_model(input_result.content)
# Evaluate output before returning to user
output_result = engine.evaluate(ai_response, trigger="output")
if output_result.action == "BLOCK":
return {"error": "Response blocked by policy"}
# Return governed response
return {"response": output_result.content}Block medical diagnoses, ensure HIPAA compliance, redact patient identifiers
Prevent unauthorized financial advice, comply with SEC regulations
Ensure brand-safe responses, block competitor mentions, enforce tone guidelines
Age-appropriate content filtering, prevent academic dishonesty patterns
Block unauthorized legal advice, ensure jurisdiction-appropriate responses
Track policy changes in Git. Review, approve, and rollback like code.
Same policies in dev, staging, and production. No configuration drift.
Every policy change is logged. Know who changed what and when.
Unit test your policies before deployment. CI/CD integration ready.
Define what you want, not how. Tork handles the implementation.
Move between frameworks without rewriting rules.