File size: 703 Bytes
0914e96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class SafetyGuard:
    # Is list ko baad mein badha sakte ho
    BLACKLIST_WORDS = {
        "ignore instructions", "system prompt", "password", "secret key", 
        "hack", "bypass"
    }

    @staticmethod
    def validate_input(text: str) -> bool:
        """Input clean hai ya nahi check karna."""
        if not text or len(text.strip()) == 0:
            return False
            
        lower_text = text.lower()
        for word in SafetyGuard.BLACKLIST_WORDS:
            if word in lower_text:
                return False # Unsafe found
        return True

    @staticmethod
    def sanitize(text: str) -> str:
        """Extra spaces clean karna."""
        return " ".join(text.split())