pyrit.executor.attack.MarkdownAttackResultPrinter#

class MarkdownAttackResultPrinter(*, display_inline: bool = True)[source]#

Bases: AttackResultPrinter

Markdown printer for attack results optimized for Jupyter notebooks.

This printer formats attack results as markdown, making them ideal for display in Jupyter notebooks where LLM responses often contain code blocks and other markdown formatting that should be properly rendered.

__init__(*, display_inline: bool = True)[source]#

Initialize the markdown printer.

Parameters:

display_inline (bool) – If True, uses IPython.display to render markdown inline in Jupyter notebooks. If False, prints markdown strings. Defaults to True.

Methods

__init__(*[, display_inline])

Initialize the markdown printer.

print_conversation_async(result, *[, ...])

Print only the conversation history as formatted markdown.

print_result_async(result, *[, ...])

Print the complete attack result as formatted markdown.

print_summary_async(result)

Print a summary of the attack result as formatted markdown.

async print_conversation_async(result: AttackResult, *, include_scores: bool = False) None[source]#

Print only the conversation history as formatted markdown.

Extracts and displays the conversation messages from the attack result without the summary or metadata sections. Useful for focusing on the actual interaction flow.

Parameters:
  • result (AttackResult) – The attack result containing the conversation to display.

  • include_scores (bool) – Whether to include scores for each message. Defaults to False.

async print_result_async(result: AttackResult, *, include_auxiliary_scores: bool = False) None[source]#

Print the complete attack result as formatted markdown.

Generates a comprehensive markdown report including attack summary, conversation history, scores, and metadata. The output is optimized for display in Jupyter notebooks.

Parameters:
  • result (AttackResult) – The attack result to print.

  • include_auxiliary_scores (bool) – Whether to include auxiliary scores in the conversation display. Defaults to False.

async print_summary_async(result: AttackResult) None[source]#

Print a summary of the attack result as formatted markdown.

Displays key information about the attack including objective, outcome, execution metrics, and final score without the full conversation history. Useful for getting a quick overview of the attack results.

Parameters:

result (AttackResult) – The attack result to summarize.