from upsonic.safety_engine.base import ActionBase
from upsonic.safety_engine.models import RuleOutput, PolicyOutput
class CompanySecretAction(ActionBase):
"""Handles company confidential content"""
name = "Company Secret Action"
description = "Blocks or redacts confidential company information"
language = "en"
def action(self, rule_result: RuleOutput) -> PolicyOutput:
"""Execute action for confidential content"""
# Allow if low confidence
if rule_result.confidence < 0.3:
return self.allow_content()
# Medium confidence: Redact keywords
if rule_result.confidence < 0.7:
return self.replace_triggered_keywords("[REDACTED]")
# High confidence: Block completely
block_message = (
"This content has been blocked because it contains "
"confidential company information. Please remove any "
"internal project names, codes, or proprietary data."
)
return self.raise_block_error(block_message)