Spaces:
Runtime error
Runtime error
| import re | |
| import sys | |
| import os | |
| # Add parent dir to path | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from app.services.medical_safety_validator import MedicalSafetyValidator | |
| def debug_validator(): | |
| validator = MedicalSafetyValidator() | |
| queries = [ | |
| "What makes CareHome different from other home care services?", | |
| "Do you provide services all over Pakistan?", | |
| "Is CareHome available 24/7?", | |
| "I have chest pain" | |
| ] | |
| print("\n🧐 Debugging MedicalSafetyValidator Patterns\n") | |
| for q in queries: | |
| print(f"Query: '{q}'") | |
| result = validator.validate_input(q) | |
| print(f" -> Is Safe: {result.is_safe}") | |
| if not result.is_safe: | |
| print(f" -> Violation: {result.violation_type}") | |
| # Find the match | |
| for pattern in validator.emergency_patterns: | |
| match = re.search(pattern, q, re.IGNORECASE) | |
| if match: | |
| print(f" -> 🚨 MATCHED PATTERN: {pattern}") | |
| print(f" -> 🚨 MATCHED STRING: '{match.group(0)}'") | |
| else: | |
| print(" -> ✅ Passed") | |
| print("-" * 40) | |
| if __name__ == "__main__": | |
| debug_validator() | |