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
14 changes: 0 additions & 14 deletions doc/code/converters/0_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,6 @@
"print(await BinaryConverter().convert_tokens_async(prompt=prompt)) # type: ignore\n",
"print(await FirstLetterConverter().convert_tokens_async(prompt=prompt)) # type: ignore"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"# Close connection\n",
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
8 changes: 0 additions & 8 deletions doc/code/converters/0_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,3 @@
print(await AsciiArtConverter().convert_tokens_async(prompt=prompt)) # type: ignore
print(await BinaryConverter().convert_tokens_async(prompt=prompt)) # type: ignore
print(await FirstLetterConverter().convert_tokens_async(prompt=prompt)) # type: ignore


# %%
# Close connection
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
13 changes: 0 additions & 13 deletions doc/code/converters/3_audio_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@
"\n",
"print(converted_audio_file)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {},
"outputs": [],
"source": [
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
6 changes: 0 additions & 6 deletions doc/code/converters/3_audio_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,3 @@
converted_audio_file = await audio_frequency_converter.convert_async(prompt=prompt) # type: ignore

print(converted_audio_file)

# %%
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
13 changes: 0 additions & 13 deletions doc/code/converters/4_image_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,6 @@
"image = Image.open(image_path)\n",
"display(image)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
6 changes: 0 additions & 6 deletions doc/code/converters/4_image_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,3 @@
image_path = output_image_file.output_text
image = Image.open(image_path)
display(image)

# %%
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
14 changes: 0 additions & 14 deletions doc/code/converters/6_human_converter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,6 @@
"result = await red_teaming_attack.execute_async(objective=conversation_objective) # type: ignore\n",
"await ConsoleAttackResultPrinter().print_conversation_async(result=result) # type: ignore"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"# Close connection\n",
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
7 changes: 0 additions & 7 deletions doc/code/converters/6_human_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,3 @@

result = await red_teaming_attack.execute_async(objective=conversation_objective) # type: ignore
await ConsoleAttackResultPrinter().print_conversation_async(result=result) # type: ignore

# %%
# Close connection
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
14 changes: 0 additions & 14 deletions doc/code/converters/transparency_attack_converter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,6 @@
"\n",
"If the model responds to the attack content (bomb-making) rather than the benign content (cake baking), the transparency attack was successful. This vulnerability underscores potential security risks: attackers could bypass content filters, poison training datasets, or mislead AI systems by disguising harmful material as benign."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"metadata": {},
"outputs": [],
"source": [
"# Close connection\n",
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
7 changes: 0 additions & 7 deletions doc/code/converters/transparency_attack_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,3 @@
# ## Analyzing the Results
#
# If the model responds to the attack content (bomb-making) rather than the benign content (cake baking), the transparency attack was successful. This vulnerability underscores potential security risks: attackers could bypass content filters, poison training datasets, or mislead AI systems by disguising harmful material as benign.

# %%
# Close connection
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
13 changes: 0 additions & 13 deletions doc/code/executor/attack/3_crescendo_attack.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1441,19 +1441,6 @@
" await ConsoleAttackResultPrinter().print_result_async(result=result) # type: ignore\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
7 changes: 0 additions & 7 deletions doc/code/executor/attack/3_crescendo_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,3 @@
for result in results:
await ConsoleAttackResultPrinter().print_result_async(result=result) # type: ignore
"""


# %%
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
18 changes: 0 additions & 18 deletions doc/code/executor/workflow/1_xpia_website.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -753,24 +753,6 @@
"print(f\"Attack result status: {result.status}\")\n",
"print(f\"Response from processing callback: {processing_response}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:pyrit.memory.sqlite_memory:Engine disposed and all connections closed.\n"
]
}
],
"source": [
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
3 changes: 0 additions & 3 deletions doc/code/executor/workflow/1_xpia_website.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,3 @@ async def processing_callback() -> str:

print(f"Attack result status: {result.status}")
print(f"Response from processing callback: {processing_response}")

# %%
memory.dispose_engine()
4 changes: 1 addition & 3 deletions doc/code/memory/1_sqlite_memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@
"\n",
"# Use in-memory database to avoid file corruption issues\n",
"memory = SQLiteMemory(db_path=\":memory:\")\n",
"memory.print_schema()\n",
"\n",
"memory.dispose_engine()"
"memory.print_schema()"
]
}
],
Expand Down
2 changes: 0 additions & 2 deletions doc/code/memory/1_sqlite_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@
# Use in-memory database to avoid file corruption issues
memory = SQLiteMemory(db_path=":memory:")
memory.print_schema()

memory.dispose_engine()
5 changes: 1 addition & 4 deletions doc/code/memory/2_basic_memory_programming.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@
"entries = memory.get_conversation(conversation_id=conversation_id)\n",
"\n",
"for entry in entries:\n",
" print(entry)\n",
"\n",
"# Cleanup memory resources\n",
"memory.dispose_engine()"
" print(entry)"
]
}
],
Expand Down
3 changes: 0 additions & 3 deletions doc/code/memory/2_basic_memory_programming.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,3 @@

for entry in entries:
print(entry)

# Cleanup memory resources
memory.dispose_engine()
6 changes: 1 addition & 5 deletions doc/code/memory/6_azure_sql_memory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,7 @@
"entries = memory.get_conversation(conversation_id=conversation_id)\n",
"\n",
"for entry in entries:\n",
" print(entry)\n",
"\n",
"\n",
"# Cleanup memory resources\n",
"memory.dispose_engine()"
" print(entry)"
]
}
],
Expand Down
4 changes: 0 additions & 4 deletions doc/code/memory/6_azure_sql_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,3 @@

for entry in entries:
print(entry)


# Cleanup memory resources
memory.dispose_engine()
14 changes: 0 additions & 14 deletions doc/code/targets/playwright_target.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,6 @@
"flask_process.wait() # Ensure the process has terminated\n",
"print(\"Flask app has been terminated.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"# Close connection to memory\n",
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
7 changes: 0 additions & 7 deletions doc/code/targets/playwright_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,3 @@ async def run() -> None:
flask_process.terminate()
flask_process.wait() # Ensure the process has terminated
print("Flask app has been terminated.")

# %%
# Close connection to memory
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
14 changes: 0 additions & 14 deletions doc/code/targets/playwright_target_copilot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,6 @@
"\n",
"asyncio.run(connect_to_existing_browser(browser_debug_port=9222, run_function=run_multimodal))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"# Close connection to memory\n",
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
7 changes: 0 additions & 7 deletions doc/code/targets/playwright_target_copilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,3 @@ async def run_multimodal(page: Page) -> None:


asyncio.run(connect_to_existing_browser(browser_debug_port=9222, run_function=run_multimodal))

# %%
# Close connection to memory
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()
13 changes: 0 additions & 13 deletions doc/code/targets/use_huggingface_chat_target.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,6 @@
"else:\n",
" print(f\"{model_id}: Error occurred, no average time calculated.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"from pyrit.memory import CentralMemory\n",
"\n",
"memory = CentralMemory.get_memory_instance()\n",
"memory.dispose_engine()"
]
}
],
"metadata": {
Expand Down
6 changes: 0 additions & 6 deletions doc/code/targets/use_huggingface_chat_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,3 @@
print(f"{model_id}: {model_times[model_id]:.2f} seconds")
else:
print(f"{model_id}: Error occurred, no average time calculated.")

# %%
from pyrit.memory import CentralMemory

memory = CentralMemory.get_memory_instance()
memory.dispose_engine()