A target that can hold a conversation
A multi-turn attack sends the target one message, reads the reply, and sends another. A target has to say it can do that. In PyRIT 1.1.0 it says so with a capability flag, not by inheriting a second class.
PromptChatTarget is gone
try:
from pyrit.prompt_target import PromptChatTarget
except ImportError as error:
print(error)Nearly every PyRIT tutorial online subclasses PromptChatTarget for a target that holds a conversation. That class no longer exists. In 1.1.0 there is one base class, PromptTarget, and a target announces what it can do through capabilities instead.
TargetCapabilities
db = await arena()
plain = ShopAssistant()
chatty = ShopAssistant(custom_configuration=CHAT)
print("plain :", plain.capabilities.supports_multi_turn)
print("chatty:", chatty.capabilities.supports_multi_turn)The same class, two configurations. CHAT in pretend_pyrit is a TargetConfiguration built with TargetCapabilities(supports_multi_turn=True, supports_editable_history=True, supports_system_prompt=True). A multi-turn attack checks supports_multi_turn before it starts, and refuses a target that cannot keep the history it needs.
from pyrit.models import TargetCapabilities
from pyrit.prompt_target import TargetConfiguration
CHAT = TargetConfiguration(
capabilities=TargetCapabilities(
supports_multi_turn=True,
supports_editable_history=True,
supports_system_prompt=True,
)
)A hosted chat endpoint sets these for you. The stand-in sets them by hand, so it can be handed to a multi-turn attack in lesson 28 and be a real conversational target to it.
- Print every field of
chatty.capabilitiesand read what else a target can declare. - Give a multi-turn attack the plain assistant and read the error about capabilities.
- Build a configuration with
supports_multi_turn=Falseand confirm the flag is off.
You understood something today that you didn't yesterday.