File size: 643 Bytes
a909949
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import Optional
from nemoguardrails.actions import action

@action(is_system_action=True)
async def check_blocked_terms(context: Optional[dict] = None):
    input = context.get("user_message")
    sensitive_information = [
        "racist",
        "sexist",
        "offensive",
        "discrimination",
        "curse",
        "profanity",
        "slur",
        "harass",
        "hate speech",
        "bully",
        "abuse",
        "vulgar",
        "derogatory",
        "insult",
        "obscene"
    ]
    for term in sensitive_information:
        if term in input.lower():
            return True

    return False