Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

Remove guards parameter make input output guards required remove unnecessary __all__

sid-murali6e77af8e5308
diff --git a/deepteam/guardrails/guardrails.py b/deepteam/guardrails/guardrails.py
index ff54a144..ed5b94f0 100644
--- a/deepteam/guardrails/guardrails.py
+++ b/deepteam/guardrails/guardrails.py
@@ -1,4 +1,4 @@
-from typing import List, Dict, Any, Optional
+from typing import List, Dict, Any
import time
import asyncio
@@ -24,9 +24,8 @@ class Guardrails:
def __init__(
self,
- input_guards: Optional[List[BaseGuard]] = None,
- output_guards: Optional[List[BaseGuard]] = None,
- guards: Optional[List[BaseGuard]] = None
+ input_guards: List[BaseGuard],
+ output_guards: List[BaseGuard]
):
"""
Initialize Guardrails with separate input and output guards.
@@ -34,14 +33,9 @@ class Guardrails:
Args:
input_guards: List of guards to check inputs before they reach your LLM
output_guards: List of guards to check outputs before they reach your users
- guards: Legacy parameter for backward compatibility
"""
- if guards is not None:
- self.input_guards = guards
- self.output_guards = guards
- else:
- self.input_guards = input_guards or []
- self.output_guards = output_guards or []
+ self.input_guards = input_guards
+ self.output_guards = output_guards
def guard_input(self, input: str) -> GuardResult:
"""
diff --git a/deepteam/guardrails/guards/__init__.py b/deepteam/guardrails/guards/__init__.py
index 9831de26..85136edd 100644
--- a/deepteam/guardrails/guards/__init__.py
+++ b/deepteam/guardrails/guards/__init__.py
@@ -16,21 +16,4 @@ from .illegal_guard import IllegalGuard
from .hallucination_guard import HallucinationGuard
from .topical_guard import TopicalGuard
from .cybersecurity_guard import CybersecurityGuard
-from .category import CyberattackCategory
-
-# Export all guards
-__all__ = [
- # Input Guards (primarily for input validation)
- "PromptInjectionGuard",
- "TopicalGuard",
-
- # Output Guards (primarily for output validation)
- "ToxicityGuard",
- "PrivacyGuard",
- "IllegalGuard",
- "HallucinationGuard",
-
- # Both Input/Output Guards
- "CybersecurityGuard",
- "CyberattackCategory",
-]
\ No newline at end of file
+from .category import CyberattackCategory
\ No newline at end of file
diff --git a/tests/test_input_output_guards.py b/tests/test_input_output_guards.py
index 66357883..877f760b 100644
--- a/tests/test_input_output_guards.py
+++ b/tests/test_input_output_guards.py
@@ -26,23 +26,13 @@ def test_basic_functionality():
print("✅ Output guarding works correctly")
-def test_backward_compatibility():
- """Test old 'guards' parameter still works"""
-
- from deepteam.guardrails import Guardrails
- from deepteam.guardrails.guards import PrivacyGuard
-
- guardrails = Guardrails(guards=[PrivacyGuard()])
- result = guardrails.guard_input("Test input")
- assert "Privacy Guard" in result.guard_results
- print("✅ Backward compatibility works")
-
-
def test_error_handling():
"""Test proper errors for empty guard lists"""
from deepteam.guardrails import Guardrails
+ from deepteam.guardrails.guards import PrivacyGuard
+ # Test with empty lists
guardrails = Guardrails(input_guards=[], output_guards=[])
# Should raise error for empty input_guards
@@ -88,7 +78,6 @@ if __name__ == "__main__":
print("🧪 Testing Guardrails Input/Output Implementation")
test_basic_functionality()
- test_backward_compatibility()
test_error_handling()
test_attack_detection()