pyrit.executor.attack.SimulatedConversationResult#
- class SimulatedConversationResult(conversation: List[Message], score: Score | None, turn_index: int | None = None)[source]#
Bases:
objectResult from generating a simulated conversation.
Stores the full conversation and provides properties to access different views of it for various attack strategy use cases.
The conversation attribute contains the complete conversation as a list of Messages (user/assistant only, no system messages). The score attribute holds the score from evaluating the final turn. The turn_index is a 1-based index of the turn to treat as the “final” turn for splitting. If None (default), uses the last turn. Can be set after creation to select an earlier turn (e.g., if the last turn’s attack didn’t work).
Methods
__init__(conversation, score[, turn_index])Attributes
Get the user message at the selected turn with a new ID.
Get all messages before the selected turn with new IDs.
- property next_message: Message | None#
Get the user message at the selected turn with a new ID.
This is the user message from the turn specified by turn_index, which can be used as the initial prompt/next_message for an attack strategy. The message is duplicated with a new ID to avoid database conflicts.
- Returns:
The user message at the selected turn with a fresh ID, or None if not found.
- Return type:
Optional[Message]
- property prepended_messages: List[Message]#
Get all messages before the selected turn with new IDs.
This returns completed turns before the turn specified by turn_index, suitable for use as prepended_conversation in attack strategies. Each message is duplicated with new IDs to avoid database conflicts when the messages are inserted into memory by a subsequent attack.
- Returns:
All messages before the selected turn with fresh IDs.
- Return type:
List[Message]