Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pyrit/output/attack_result/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ async def _render_conversation_async(
include_reasoning_trace=include_reasoning_trace,
)

async def print_conversation_async(
self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False
) -> None:
"""Use ``write_async`` instead. This method is deprecated."""
print_deprecation_message(old_item="print_conversation_async", new_item="write_async", removed_in="2.0")
content = await self._render_conversation_async(
result, include_scores=include_scores, include_reasoning_trace=include_reasoning_trace
)
await self._write_async(content)

async def output_conversation_async(
self, result: AttackResult, *, include_scores: bool = False, include_reasoning_trace: bool = False
) -> None:
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/output/attack_result/test_pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ async def test_print_result_async_emits_deprecation_warning_and_still_writes(pri
assert "ATTACK RESULT" in capsys.readouterr().out


async def test_print_conversation_async_emits_deprecation_warning(printer, attack_result, capsys):
with pytest.warns(DeprecationWarning, match="print_conversation_async"):
await printer.print_conversation_async(attack_result)
assert "No conversation found" in capsys.readouterr().out


async def test_output_conversation_async_emits_deprecation_warning(printer, attack_result, capsys):
with pytest.warns(DeprecationWarning, match="output_conversation_async"):
await printer.output_conversation_async(attack_result)
Expand Down
Loading