DeepTeam is a framework to red team LLMs and AI agents.
Add NoAttack class and fix for empty attacks in yml
rauschecker8f6d4e9a692d
diff --git a/deepteam/attacks/attack_simulator/attack_simulator.py b/deepteam/attacks/attack_simulator/attack_simulator.pyindex aca9710b..305b7eb4 100644--- a/deepteam/attacks/attack_simulator/attack_simulator.py+++ b/deepteam/attacks/attack_simulator/attack_simulator.py@@ -24,6 +24,12 @@ class SimulatedAttack(BaseModel):attack_method: Optional[str] = Noneerror: Optional[str] = None+class NoAttack:+ def get_name(self):+ return "NoAttack"++ async def a_enhance(self, attack, *args, **kwargs):+ return attackclass AttackSimulator:model_callback: Union[CallbackType, None] = None@@ -149,13 +155,14 @@ class AttackSimulator:):async with semaphore: # Throttling applied here# Randomly sample an enhancement based on the distribution- attack_weights = [attack.weight for attack in attacks]- sampled_attack = random.choices(- attacks, weights=attack_weights, k=1- )[0]+ if not attacks:+ attack = NoAttack()+ else:+ attack_weights = [attack.weight for attack in attacks]+ attack = random.choices(attacks, weights=attack_weights, k=1)[0]result = await self.a_enhance_attack(- attack=sampled_attack,+ attack=attack,simulated_attack=baseline_attack,ignore_errors=ignore_errors,)