Skip to content

Commit 403fd6f

Browse files
authored
BREAKING MAINT rename PromptRequestResponse to Message, and PromptRequestPiece to MessagePiece (#1141)
1 parent 193d63f commit 403fd6f

287 files changed

Lines changed: 4772 additions & 4095 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/instructions/style-guide.instructions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Follow these coding standards to ensure consistent, readable, and maintainable c
1414

1515
```python
1616
# CORRECT
17-
async def send_prompt_async(self, prompt: str) -> PromptResponse:
17+
async def send_prompt_async(self, prompt: str) -> Message:
1818
...
1919

2020
# INCORRECT
21-
async def send_prompt(self, prompt: str) -> PromptResponse: # Missing _async suffix
21+
async def send_prompt(self, prompt: str) -> Message: # Missing _async suffix
2222
...
2323
```
2424

@@ -230,7 +230,7 @@ from tqdm import tqdm
230230

231231
# Local application imports
232232
from pyrit.attacks.base import AttackStrategy
233-
from pyrit.models import AttackResult, PromptResponse
233+
from pyrit.models import AttackResult
234234
from pyrit.prompt_target import PromptTarget
235235
```
236236

assets/prompt_request_piece.png

-45.7 KB
Binary file not shown.

doc/api.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ API Reference
1212
:nosignatures:
1313
:toctree: _autosummary/
1414

15+
analyze_results
16+
AttackStats
1517
ConversationAnalytics
1618

1719
:py:mod:`pyrit.auth`
@@ -312,14 +314,13 @@ API Reference
312314
EmbeddingSupport
313315
EmbeddingUsageInformation
314316
ErrorDataTypeSerializer
315-
group_conversation_request_pieces_by_sequence
317+
group_conversation_message_pieces_by_sequence
316318
Identifier
317319
ImagePathDataTypeSerializer
318-
PromptRequestPiece
319-
PromptResponse
320-
PromptResponseError
320+
Message
321+
MessagePiece
321322
PromptDataType
322-
PromptRequestResponse
323+
PromptResponseError
323324
QuestionAnsweringDataset
324325
QuestionAnsweringEntry
325326
QuestionChoice

doc/code/converters/3_audio_converters.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"source": [
88
"# 3. Audio Converters\n",
99
"\n",
10-
"Converters can also be multi-modal. Because it's an abstract function used interchangeably on a single `PromptRequestPiece`, it can only deal with one input value and type per time, and have one output value and type per time. Below is an example of using `AzureSpeechTextToAudioConverter`, which has an input type of `text` and an output type of `audio_path`."
10+
"Converters can also be multi-modal. Because it's an abstract function used interchangeably on a single `MessagePiece`, it can only deal with one input value and type per time, and have one output value and type per time. Below is an example of using `AzureSpeechTextToAudioConverter`, which has an input type of `text` and an output type of `audio_path`."
1111
]
1212
},
1313
{

doc/code/converters/3_audio_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# %% [markdown]
1313
# # 3. Audio Converters
1414
#
15-
# Converters can also be multi-modal. Because it's an abstract function used interchangeably on a single `PromptRequestPiece`, it can only deal with one input value and type per time, and have one output value and type per time. Below is an example of using `AzureSpeechTextToAudioConverter`, which has an input type of `text` and an output type of `audio_path`.
15+
# Converters can also be multi-modal. Because it's an abstract function used interchangeably on a single `MessagePiece`, it can only deal with one input value and type per time, and have one output value and type per time. Below is an example of using `AzureSpeechTextToAudioConverter`, which has an input type of `text` and an output type of `audio_path`.
1616

1717
# %%
1818
import os

doc/code/executor/attack/1_prompt_sending_attack.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,15 +977,15 @@
977977
"source": [
978978
"from pyrit.datasets import TextJailBreak\n",
979979
"from pyrit.executor.attack import AttackExecutor, PromptSendingAttack\n",
980-
"from pyrit.models.prompt_request_response import PromptRequestResponse\n",
980+
"from pyrit.models import Message\n",
981981
"from pyrit.prompt_target import OpenAIChatTarget\n",
982982
"\n",
983983
"target = OpenAIChatTarget()\n",
984984
"\n",
985985
"jailbreak = TextJailBreak(template_file_name=\"dan_1.yaml\")\n",
986986
"system_prompt_str = jailbreak.get_jailbreak_system_prompt()\n",
987987
"\n",
988-
"prepend_conversation = [PromptRequestResponse.from_system_prompt(system_prompt_str)]\n",
988+
"prepend_conversation = [Message.from_system_prompt(system_prompt_str)]\n",
989989
"\n",
990990
"attack = PromptSendingAttack(objective_target=target)\n",
991991
"executor = AttackExecutor()\n",

doc/code/executor/attack/1_prompt_sending_attack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,15 @@
211211
# %%
212212
from pyrit.datasets import TextJailBreak
213213
from pyrit.executor.attack import AttackExecutor, PromptSendingAttack
214-
from pyrit.models.prompt_request_response import PromptRequestResponse
214+
from pyrit.models import Message
215215
from pyrit.prompt_target import OpenAIChatTarget
216216

217217
target = OpenAIChatTarget()
218218

219219
jailbreak = TextJailBreak(template_file_name="dan_1.yaml")
220220
system_prompt_str = jailbreak.get_jailbreak_system_prompt()
221221

222-
prepend_conversation = [PromptRequestResponse.from_system_prompt(system_prompt_str)]
222+
prepend_conversation = [Message.from_system_prompt(system_prompt_str)]
223223

224224
attack = PromptSendingAttack(objective_target=target)
225225
executor = AttackExecutor()

doc/code/executor/attack/2_red_teaming_attack.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@
335335
"import os\n",
336336
"\n",
337337
"from pyrit.datasets import TextJailBreak\n",
338-
"from pyrit.models import PromptRequestPiece, PromptRequestResponse\n",
338+
"from pyrit.models import Message, MessagePiece\n",
339339
"\n",
340340
"jailbreak = TextJailBreak(template_file_name=\"dan_1.yaml\")\n",
341341
"\n",
342342
"prepended_conversation = [\n",
343-
" PromptRequestResponse(\n",
344-
" request_pieces=[\n",
345-
" PromptRequestPiece(\n",
343+
" Message(\n",
344+
" message_pieces=[\n",
345+
" MessagePiece(\n",
346346
" role=\"system\",\n",
347347
" original_value=jailbreak.get_jailbreak_system_prompt(),\n",
348348
" )\n",
@@ -378,9 +378,9 @@
378378
"# To customize the last user message sent to the objective target:\n",
379379
"\"\"\"\n",
380380
"prepended_conversation.append(\n",
381-
" PromptRequestResponse(\n",
382-
" request_pieces=[\n",
383-
" PromptRequestPiece(\n",
381+
" Message(\n",
382+
" message_pieces=[\n",
383+
" MessagePiece(\n",
384384
" role=\"user\",\n",
385385
" original_value=\"Custom message to continue the conversation with the objective target\",\n",
386386
" )\n",

doc/code/executor/attack/2_red_teaming_attack.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@
120120
import os
121121

122122
from pyrit.datasets import TextJailBreak
123-
from pyrit.models import PromptRequestPiece, PromptRequestResponse
123+
from pyrit.models import Message, MessagePiece
124124

125125
jailbreak = TextJailBreak(template_file_name="dan_1.yaml")
126126

127127
prepended_conversation = [
128-
PromptRequestResponse(
129-
request_pieces=[
130-
PromptRequestPiece(
128+
Message(
129+
message_pieces=[
130+
MessagePiece(
131131
role="system",
132132
original_value=jailbreak.get_jailbreak_system_prompt(),
133133
)
@@ -163,9 +163,9 @@
163163
# To customize the last user message sent to the objective target:
164164
"""
165165
prepended_conversation.append(
166-
PromptRequestResponse(
167-
request_pieces=[
168-
PromptRequestPiece(
166+
Message(
167+
message_pieces=[
168+
MessagePiece(
169169
role="user",
170170
original_value="Custom message to continue the conversation with the objective target",
171171
)

doc/code/executor/workflow/1_xpia_website.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391
"from pyrit.memory import CentralMemory\n",
392392
"\n",
393393
"memory = CentralMemory.get_memory_instance()\n",
394-
"processing_response = memory.get_prompt_request_pieces(conversation_id=result.processing_conversation_id)\n",
394+
"processing_response = memory.get_message_pieces(conversation_id=result.processing_conversation_id)\n",
395395
"\n",
396396
"print(f\"Attack result status: {result.status}\")\n",
397397
"print(f\"Response from processing callback: {processing_response}\")"

0 commit comments

Comments
 (0)