Skip to content

Commit c5169eb

Browse files
author
Behnam Ousat
committed
ruff
1 parent 8c6c5ce commit c5169eb

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

doc/code/memory/5_advanced_memory.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"name": "stdout",
4343
"output_type": "stream",
4444
"text": [
45-
"Found default environment files: ['C:\\\\Users\\\\behnamousat\\\\.pyrit\\\\.env']\n",
46-
"Loaded environment file: C:\\Users\\behnamousat\\.pyrit\\.env\n",
45+
"Found default environment files: ['./.pyrit/.env']\n",
46+
"Loaded environment file: ./.pyrit/.env\n",
4747
"\n",
4848
"\u001b[34m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n",
4949
"\u001b[1m\u001b[34m🔹 Turn 1 - USER\u001b[0m\n",
@@ -131,7 +131,7 @@
131131
"name": "stderr",
132132
"output_type": "stream",
133133
"text": [
134-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_16856\\1441526989.py:17: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
134+
"./AppData/Local/Temp/ipykernel_16856/1441526989.py:17: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
135135
" original_user_prompts = [prompt.original_value for prompt in prompts if prompt.role == \"user\"]\n",
136136
"[PromptSendingAttack (ID: 1cb5c9f1)] No response received on attempt 1 (likely filtered)\n"
137137
]
@@ -277,7 +277,7 @@
277277
"name": "stderr",
278278
"output_type": "stream",
279279
"text": [
280-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_16856\\4148307427.py:19: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
280+
"./AppData/Local/Temp/ipykernel_16856/4148307427.py:19: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
281281
" print(f\" [{piece.role}] {piece.converted_value[:80]}\")\n"
282282
]
283283
}
@@ -336,7 +336,7 @@
336336
"name": "stderr",
337337
"output_type": "stream",
338338
"text": [
339-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_13356\\2793915745.py:15: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
339+
"./AppData/Local/Temp/ipykernel_13356/2793915745.py:15: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
340340
" print(f\" [{piece.role}] {piece.original_value[:80]}\")\n"
341341
]
342342
}
@@ -389,7 +389,7 @@
389389
"name": "stderr",
390390
"output_type": "stream",
391391
"text": [
392-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_13356\\3979432580.py:15: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
392+
"./AppData/Local/Temp/ipykernel_13356/3979432580.py:15: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
393393
" print(f\" [{piece.role}] original: {piece.original_value[:60]} → converted: {piece.converted_value[:60]}\")\n"
394394
]
395395
}
@@ -442,7 +442,7 @@
442442
"name": "stderr",
443443
"output_type": "stream",
444444
"text": [
445-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_13356\\814594877.py:13: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
445+
"./AppData/Local/Temp/ipykernel_13356/814594877.py:13: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
446446
" print(f\" [{piece.role}] {piece.original_value[:80]}\")\n"
447447
]
448448
}
@@ -494,7 +494,7 @@
494494
"name": "stderr",
495495
"output_type": "stream",
496496
"text": [
497-
"C:\\Users\\behnamousat\\AppData\\Local\\Temp\\ipykernel_13356\\2461341104.py:9: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
497+
"./AppData/Local/Temp/ipykernel_13356/2461341104.py:9: DeprecationWarning: MessagePiece.role getter is deprecated. Use api_role for comparisons. This property will be removed in 0.13.0.\n",
498498
" print(f\" [{piece.role}] {piece.original_value[:80]}\")\n"
499499
]
500500
}
@@ -548,7 +548,9 @@
548548
"# Create three scorers with different substrings\n",
549549
"scorer_molotov = SubStringScorer(substring=\"molotov\")\n",
550550
"scorer_launder = SubStringScorer(substring=\"launder\")\n",
551-
"scorer_assist = SubStringScorer(substring=\"assist\") # intentionally bad scorer that matches when the phrase 'assist' is present in response. But good for demo.\n",
551+
"scorer_assist = SubStringScorer(\n",
552+
" substring=\"assist\"\n",
553+
") # intentionally bad scorer that matches when the phrase 'assist' is present in response. But good for demo.\n",
552554
"\n",
553555
"# Retrieve assistant responses from Part 1\n",
554556
"assistant_pieces = memory.get_message_pieces(\n",
@@ -699,7 +701,7 @@
699701
"\n",
700702
"print(f\"Scores from the 'assist' SubStringScorer: {len(assist_scores)}\")\n",
701703
"for s in assist_scores:\n",
702-
" print(f\" score={s.get_value()} category={s.score_category}\")\n"
704+
" print(f\" score={s.get_value()} category={s.score_category}\")"
703705
]
704706
}
705707
],

doc/code/memory/5_advanced_memory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616
# 1. **Memory Labels** — free-form key/value tags attached to every prompt, useful for grouping and retrieval.
1717
# 2. **Identifier Filters** — structured filters that match against the JSON-backed identifier columns
18-
# (target, converter, scorer, attack) stored alongside different memory entities, such as `MessagePiece`, `AttackResult`, etc.
18+
# (target, converter, scorer, attack) stored alongside different memory entities, such as `MessagePiece`, `AttackResult`, etc.
1919
# This notebook demonstrates the functionality with `MessagePiece` entities, but the concepts are similar for other memory entities.
2020
# 3. **Score Identifier Filters** — the same `IdentifierFilter` mechanism applied to `memory.get_scores()` for
2121
# retrieving scores by scorer identity (class name, custom parameters, etc.).
@@ -254,7 +254,9 @@
254254
# Create three scorers with different substrings
255255
scorer_molotov = SubStringScorer(substring="molotov")
256256
scorer_launder = SubStringScorer(substring="launder")
257-
scorer_assist = SubStringScorer(substring="assist") # intentionally bad scorer that matches when the phrase 'assist' is present in response. But good for demo.
257+
scorer_assist = SubStringScorer(
258+
substring="assist"
259+
) # intentionally bad scorer that matches when the phrase 'assist' is present in response. But good for demo.
258260

259261
# Retrieve assistant responses from Part 1
260262
assistant_pieces = memory.get_message_pieces(

0 commit comments

Comments
 (0)