DeepTeam is a framework to red team LLMs and AI agents.
.
sid-murali290b28bdcf2f
diff --git a/deepteam/guardrails/base_guard.py b/deepteam/guardrails/base_guard.pyindex d3058779..c225f3cb 100644--- a/deepteam/guardrails/base_guard.py+++ b/deepteam/guardrails/base_guard.py@@ -1,9 +1,9 @@from abc import ABC, abstractmethod-from typing import Optional, Dict-from deepeval.models import GPTModel+from typing import Optional, Dict, Unionfrom deepeval.models.llms.utils import trim_and_load_jsonimport jsonfrom deepteam.guardrails.types import GuardType+from deepteam.cli.model_callback import load_modelclass BaseGuard(ABC):score: Optional[float] = None@@ -13,8 +13,8 @@ class BaseGuard(ABC):latency: Optional[float] = Noneguard_type: GuardType- def __init__(self, evaluation_model: str = "gpt-4.1"):- self.model = GPTModel(model=evaluation_model)+ def __init__(self, evaluation_model: Union[str, Dict] = "gpt-4.1"):+ self.model = load_model(evaluation_model)self.evaluation_model = self.model.get_model_name()@propertydiff --git a/deepteam/guardrails/guardrails.py b/deepteam/guardrails/guardrails.pyindex 42acab56..f2cb9774 100644--- a/deepteam/guardrails/guardrails.py+++ b/deepteam/guardrails/guardrails.py@@ -1,4 +1,4 @@-from typing import List, Dict, Any+from typing import List, Dict, Any, Unionimport timeimport asyncio@@ -28,7 +28,7 @@ class Guardrails:self,input_guards: List[BaseGuard],output_guards: List[BaseGuard],- evaluation_model: str = "gpt-4.1",+ evaluation_model: Union[str, Dict] = "gpt-4.1",sample_rate: float = 1.0):"""@@ -37,7 +37,8 @@ class Guardrails:Args:input_guards: List of guards to check inputs before they reach your LLMoutput_guards: List of guards to check outputs before they reach your users- evaluation_model: OpenAI model to use for guard evaluation (default: gpt-4.1)+ evaluation_model: Model specification (string or dict) for guard evaluation (default: "gpt-4.1")+ Supports OpenAI, Azure, Anthropic, Gemini, Ollama, Custom modelssample_rate: Fraction of requests to actually guard (0.0 to 1.0, default: 1.0)"""# Validate sample_rate@@ -52,7 +53,7 @@ class Guardrails:self.input_guards = self._update_guards_model(input_guards, evaluation_model)self.output_guards = self._update_guards_model(output_guards, evaluation_model)- def _update_guards_model(self, guards: List[BaseGuard], evaluation_model: str) -> List[BaseGuard]:+ def _update_guards_model(self, guards: List[BaseGuard], evaluation_model: Union[str, Dict]) -> List[BaseGuard]:"""Update all guards to use the specified evaluation model"""updated_guards = []for guard in guards:diff --git a/deepteam/guardrails/guards/illegal_guard.py b/deepteam/guardrails/guards/illegal_guard.pyindex 6c53750e..2365e334 100644--- a/deepteam/guardrails/guards/illegal_guard.py+++ b/deepteam/guardrails/guards/illegal_guard.py@@ -1,10 +1,10 @@from ..base_guard import BaseGuardfrom ..types import GuardType-from typing import Optional+from typing import Union, Dictclass IllegalGuard(BaseGuard):- def __init__(self, evaluation_model: Optional[str] = None):+ def __init__(self, evaluation_model: Union[str, Dict] = "gpt-4.1"):super().__init__(evaluation_model=evaluation_model)self.guard_type = GuardType.OUTPUTdiff --git a/deepteam/guardrails/guards/prompt_injection_guard.py b/deepteam/guardrails/guards/prompt_injection_guard.pyindex 8155ad42..d8c783b1 100644--- a/deepteam/guardrails/guards/prompt_injection_guard.py+++ b/deepteam/guardrails/guards/prompt_injection_guard.py@@ -1,9 +1,10 @@from ..base_guard import BaseGuardfrom ..types import GuardType+from typing import Union, Dictclass PromptInjectionGuard(BaseGuard):- def __init__(self, evaluation_model: str = "gpt-4.1"):+ def __init__(self, evaluation_model: Union[str, Dict] = "gpt-4.1"):super().__init__(evaluation_model=evaluation_model)self.guard_type = GuardType.INPUTdiff --git a/deepteam/guardrails/guards/topical_guard.py b/deepteam/guardrails/guards/topical_guard.pyindex f9c8c2cc..d2743810 100644--- a/deepteam/guardrails/guards/topical_guard.py+++ b/deepteam/guardrails/guards/topical_guard.py@@ -1,13 +1,19 @@from ..base_guard import BaseGuardfrom ..types import GuardType-from typing import Optional+from typing import Union, Dict, Listclass TopicalGuard(BaseGuard):- def __init__(self, allowed_topics=None, evaluation_model: Optional[str] = None):+ def __init__(+ self,+ evaluation_model: Union[str, Dict] = "gpt-4.1",+ allowed_topics: List[str] = None,+ description: str = None+ ):super().__init__(evaluation_model=evaluation_model)self.guard_type = GuardType.INPUTself.allowed_topics = allowed_topics or []+ self.description = description or "General conversation topics"@propertydef __name__(self):diff --git a/deepteam/guardrails/guards/toxicity_guard.py b/deepteam/guardrails/guards/toxicity_guard.pyindex b3191748..e9227d3e 100644--- a/deepteam/guardrails/guards/toxicity_guard.py+++ b/deepteam/guardrails/guards/toxicity_guard.py@@ -1,9 +1,10 @@from ..base_guard import BaseGuardfrom ..types import GuardType+from typing import Union, Dictclass ToxicityGuard(BaseGuard):- def __init__(self, evaluation_model: str = "gpt-4.1"):+ def __init__(self, evaluation_model: Union[str, Dict] = "gpt-4.1"):super().__init__(evaluation_model=evaluation_model)self.guard_type = GuardType.OUTPUT