Registering and loading an attack¶
load_attack
¶
load_attack(
attack_name: str,
task_suite: TaskSuite,
target_pipeline: BasePipelineElement,
) -> BaseAttack
Gets and instantiates an attack from the registry.
To use your own attack, you must first register it using the register_attack
function.
Parameters:
-
attack_name
(str
) –The name of the attack to load.
-
task_suite
(TaskSuite
) –The task suite to use for the attack.
-
target_pipeline
(BasePipelineElement
) –The target pipeline to attack.
Source code in src/agentdojo/attacks/attack_registry.py
40 41 42 43 44 45 46 47 48 49 50 |
|
register_attack
¶
Adds an attack to the registry.
It can be used both as a function call or as a decorator.
For example:
@register_attack
class MyAttack(BaseAttack): ...
Or:
class MyAttack(BaseAttack): ...
register_attack(MyAttack)
Parameters:
-
attack
(type[A]
) –The attack class to register.
Source code in src/agentdojo/attacks/attack_registry.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|