PyRIT icon indicating copy to clipboard operation
PyRIT copied to clipboard

FEAT: Add Image functionality to TAP

Open awksrj opened this issue 4 months ago • 2 comments

Description

This PR adds a code cell to tree_of_attacks_with_pruning.ipynb to demonstrate an image target example and modifies tree_of_attacks.py to adapt the Tree of Attacks orchestrator for image targets, particularly adding a dictionary to map content_policy_violation errors to an objective_score of 0.0, which ensure nodes are kept in the completed nodes list until the branch width limit is exceeded to prevent premature pruning.

Related Issue

Closes: #585

Tests and Documentation

No tests included in this commit.

awksrj avatar Jul 30 '25 15:07 awksrj

Thanks for all the comments. I'll go through them and push changes soon!

awksrj avatar Aug 01 '25 16:08 awksrj

I added two unit tests to cover the pruning logic, ensuring blocked responses are scored as 0.0 and pruning only occurs when we exceed tree_width. I also updated the example in tree_of_attacks_with_pruning.py, which used to show how the old TreeOfAttacksWithPruningOrchestrator worked with text targets. I replaced it with the new TAPAttack class to reflect the current implementation, which hopefully makes the documentation more complete.

awksrj avatar Aug 06 '25 15:08 awksrj