| class SafetyGuard: | |
| # Is list ko baad mein badha sakte ho | |
| BLACKLIST_WORDS = { | |
| "ignore instructions", "system prompt", "password", "secret key", | |
| "hack", "bypass" | |
| } | |
| 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 | |
| def sanitize(text: str) -> str: | |
| """Extra spaces clean karna.""" | |
| return " ".join(text.split()) |