Skip to content

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

custom simplified

sid-muraliafb44fed502f
diff --git a/deepteam/vulnerabilities/custom/__init__.py b/deepteam/vulnerabilities/custom/__init__.py
index 514f3c07..16ec60cb 100644
--- a/deepteam/vulnerabilities/custom/__init__.py
+++ b/deepteam/vulnerabilities/custom/__init__.py
@@ -1,3 +1,3 @@
-from .custom_types import register_vulnerability_type, get_registered_types, is_registered_type, CustomVulnerabilityType
+from .custom_types import CustomVulnerabilityType
from .template import CustomVulnerabilityTemplate
from .custom import CustomVulnerability
\ No newline at end of file
diff --git a/deepteam/vulnerabilities/custom/custom.py b/deepteam/vulnerabilities/custom/custom.py
index d7e1f7e8..e8047564 100644
--- a/deepteam/vulnerabilities/custom/custom.py
+++ b/deepteam/vulnerabilities/custom/custom.py
@@ -1,14 +1,7 @@
-from typing import List, Optional, Dict, Any
-from enum import Enum
+from typing import List, Optional
from deepteam.vulnerabilities import BaseVulnerability
-from deepteam.vulnerabilities.custom.custom_types import (
- register_vulnerability_type,
- is_registered_type,
- get_registered_types,
- CUSTOM_VULNERABILITY_REGISTRY,
- CustomVulnerabilityType
-)
+from deepteam.vulnerabilities.custom.custom_types import CustomVulnerabilityType
class CustomVulnerability(BaseVulnerability):
"""
@@ -25,20 +18,13 @@ class CustomVulnerability(BaseVulnerability):
self.raw_types = types or []
self.custom_prompt = custom_prompt
-
- for type_value in self.raw_types:
- register_vulnerability_type(type_value)
-
- CUSTOM_VULNERABILITY_REGISTRY[name] = self
- enum_types = []
- for type_value in self.raw_types:
- try:
- enum_type = CustomVulnerabilityType.CUSTOM_VULNERABILITY
- if custom_prompt:
- enum_type.set_custom_prompt(custom_prompt)
- enum_types.append(enum_type)
- except ValueError:
- raise ValueError(f"Unknown custom vulnerability type: {type_value}")
+ # Create enum types for each raw type
+ enum_types = [CustomVulnerabilityType.CUSTOM_VULNERABILITY for _ in self.raw_types]
+
+ # Set custom prompt if provided
+ if custom_prompt:
+ for enum_type in enum_types:
+ enum_type.set_custom_prompt(custom_prompt)
super().__init__(types=enum_types)
@@ -52,12 +38,3 @@ class CustomVulnerability(BaseVulnerability):
"""Get the original string type values"""
return self.raw_types
- @staticmethod
- def get_instance(instance_name: str) -> Optional[Any]:
- return CUSTOM_VULNERABILITY_REGISTRY.get(instance_name)
-
- @staticmethod
- def get_all_instances() -> Dict[str, Any]:
- return CUSTOM_VULNERABILITY_REGISTRY
-
-
diff --git a/deepteam/vulnerabilities/custom/custom_types.py b/deepteam/vulnerabilities/custom/custom_types.py
index e93d1598..cf3a4b4c 100644
--- a/deepteam/vulnerabilities/custom/custom_types.py
+++ b/deepteam/vulnerabilities/custom/custom_types.py
@@ -1,24 +1,5 @@
from enum import Enum
-from typing import Dict, Optional, List, Set, Any, Type
-
-
-
-CUSTOM_VULNERABILITY_TYPES: Set[str] = set()
-CUSTOM_VULNERABILITY_REGISTRY: Dict[str, Any] = {}
-
-
-def register_vulnerability_type(type_value: str) -> None:
- """Register a new vulnerability type"""
- CUSTOM_VULNERABILITY_TYPES.add(type_value)
-
-
-def get_registered_types() -> Set[str]:
- return CUSTOM_VULNERABILITY_TYPES
-
-
-def is_registered_type(type_value: str) -> bool:
- return type_value in CUSTOM_VULNERABILITY_TYPES
-
+from typing import Optional
class CustomVulnerabilityType(Enum):
"""Custom vulnerability type enum with prompt support"""
diff --git a/deepteam/vulnerabilities/custom/template.py b/deepteam/vulnerabilities/custom/template.py
index 06389e3f..34dc3f42 100644
--- a/deepteam/vulnerabilities/custom/template.py
+++ b/deepteam/vulnerabilities/custom/template.py
@@ -1,8 +1,5 @@
from typing import Optional, List
-from deepteam.vulnerabilities.custom.custom_types import is_registered_type
-
-
class CustomVulnerabilityTemplate:
"""
Template generator for custom vulnerability attacks.