DeepTeam is a framework to red team LLMs and AI agents.
added criterion
sid-murali1d6cd43fe526
diff --git a/deepteam/cli/main.py b/deepteam/cli/main.pyindex c93f4ac7..107c456e 100644--- a/deepteam/cli/main.py+++ b/deepteam/cli/main.py@@ -91,6 +91,7 @@ def _build_vulnerability(cfg: dict):name=cfg.get("custom_name", "Custom"),types=cfg.get("types"),custom_prompt=cfg.get("prompt"),+ criterion=cfg.get("criterion"),)cls = VULN_MAP.get(name)if not cls:diff --git a/deepteam/red_teamer/red_teamer.py b/deepteam/red_teamer/red_teamer.pyindex 73863270..68073137 100644--- a/deepteam/red_teamer/red_teamer.py+++ b/deepteam/red_teamer/red_teamer.py@@ -634,9 +634,16 @@ class RedTeamer:if metric:metrics_map[vuln_type] = lambda: metricelse:- metrics_map[vuln_type] = lambda: HarmMetric(+ # Use the custom criterion as harm_category, or fall back to a readable default+ criterion = vulnerability.get_criterion()+ if criterion:+ harm_category = criterion+ else:+ harm_category = f"{vulnerability.get_name()} - {', '.join(vulnerability.get_raw_types())}"++ metrics_map[vuln_type] = lambda hc=harm_category: HarmMetric(model=self.evaluation_model,- harm_category=f"{vulnerability}.{vuln_type}",+ harm_category=hc,async_mode=self.async_mode,)diff --git a/deepteam/vulnerabilities/custom/custom.py b/deepteam/vulnerabilities/custom/custom.pyindex 230511dd..b844c23e 100644--- a/deepteam/vulnerabilities/custom/custom.py+++ b/deepteam/vulnerabilities/custom/custom.py@@ -16,6 +16,7 @@ class CustomVulnerability(BaseVulnerability):types: Optional[List[str]] = None,custom_prompt: Optional[str] = None,metric: Optional[BaseRedTeamingMetric] = None,+ criterion: Optional[str] = None,):self.name = nameself.types = [@@ -24,6 +25,7 @@ class CustomVulnerability(BaseVulnerability):self.raw_types = types or []self.custom_prompt = custom_promptself.metric = metric+ self.criterion = criterionsuper().__init__(self.types)def get_name(self) -> str:@@ -37,3 +39,6 @@ class CustomVulnerability(BaseVulnerability):def get_raw_types(self) -> List[str]:return self.raw_types++ def get_criterion(self) -> Optional[str]:+ return self.criterion