PyRITpyrit 1.1.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
36 small wins to finish your pathNext lesson

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

Example
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

Example
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.

python
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.

Try it yourself
  • Print every field of chatty.capabilities and 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=False and confirm the flag is off.

You understood something today that you didn't yesterday.