Skip to content

Commit b95add6

Browse files
authored
FEAT Add separator support for FirstLetterConverter (Azure#1070)
1 parent a4a04a9 commit b95add6

File tree

6 files changed

+117
-20
lines changed

6 files changed

+117
-20
lines changed

doc/code/converters/0_converters.ipynb

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,32 @@
4747
"output_type": "stream",
4848
"text": [
4949
"text: gryy zr ubj gb phg qbja n gerr\n",
50-
"text: TEll me how To cUt down a Tree\n",
51-
"text: \n",
52-
" o 8 8 8 o o 8 o \n",
53-
" 8 8 8 8 8 8 8 8 \n",
54-
" o8P .oPYo. 8 8 ooYoYo. .oPYo. 8oPYo. .oPYo. o o o o8P .oPYo. .oPYo. o o o8P .oPYo8 .oPYo. o o o odYo. .oPYo. o8P oPYo. .oPYo. .oPYo. \n",
55-
" 8 8oooo8 8 8 8' 8 8 8oooo8 8 8 8 8 Y. .P. .P 8 8 8 8 ' 8 8 8 8 8 8 8 Y. .P. .P 8' `8 .oooo8 8 8 `' 8oooo8 8oooo8 \n",
56-
" 8 8. 8 8 8 8 8 8. 8 8 8 8 `b.d'b.d' 8 8 8 8 . 8 8 8 8 8 8 8 `b.d'b.d' 8 8 8 8 8 8 8. 8. \n",
57-
" 8 `Yooo' 8 8 8 8 8 `Yooo' 8 8 `YooP' `Y' `Y' 8 `YooP' `YooP' `YooP' 8 `YooP' `YooP' `Y' `Y' 8 8 `YooP8 8 8 `Yooo' `Yooo' \n",
58-
"::..::.....:....::..:..:..:.....:::..:::..:.....:::..::..::::::..::.....::::.....::.....:::..::::.....::.....:::..::..::..::..:::.....:::::..:..:::::.....::.....:\n",
59-
"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n",
60-
"::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n",
50+
"text: tell me how tO cuT down A trEe\n",
51+
"text: _____ _____ _____ _____ _____ _____ _____ _______ _____ _____ _______ _____ _____ _____ _____ _______ _____ _____ _____ _____ _____ _____ _____ \n",
52+
" /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /::\\ \\ /\\ \\ /\\ \\ /::\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /::\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ \n",
53+
" /::\\ \\ /::\\ \\ /::\\____\\ /::\\____\\ /::\\____\\ /::\\ \\ /::\\____\\ /::::\\ \\ /::\\____\\ /::\\ \\ /::::\\ \\ /::\\ \\ /::\\____\\ /::\\ \\ /::\\ \\ /::::\\ \\ /::\\____\\ /::\\____\\ /::\\ \\ /::\\ \\ /::\\ \\ /::\\ \\ /::\\ \\ \n",
54+
" \\:::\\ \\ /::::\\ \\ /:::/ / /:::/ / /::::| | /::::\\ \\ /:::/ / /::::::\\ \\ /:::/ / \\:::\\ \\ /::::::\\ \\ /::::\\ \\ /:::/ / \\:::\\ \\ /::::\\ \\ /::::::\\ \\ /:::/ / /::::| | /::::\\ \\ \\:::\\ \\ /::::\\ \\ /::::\\ \\ /::::\\ \\ \n",
55+
" \\:::\\ \\ /::::::\\ \\ /:::/ / /:::/ / /:::::| | /::::::\\ \\ /:::/ / /::::::::\\ \\ /:::/ _/___ \\:::\\ \\ /::::::::\\ \\ /::::::\\ \\ /:::/ / \\:::\\ \\ /::::::\\ \\ /::::::::\\ \\ /:::/ _/___ /:::::| | /::::::\\ \\ \\:::\\ \\ /::::::\\ \\ /::::::\\ \\ /::::::\\ \\ \n",
56+
" \\:::\\ \\ /:::/\\:::\\ \\ /:::/ / /:::/ / /::::::| | /:::/\\:::\\ \\ /:::/ / /:::/~~\\:::\\ \\ /:::/ /\\ \\ \\:::\\ \\ /:::/~~\\:::\\ \\ /:::/\\:::\\ \\ /:::/ / \\:::\\ \\ /:::/\\:::\\ \\ /:::/~~\\:::\\ \\ /:::/ /\\ \\ /::::::| | /:::/\\:::\\ \\ \\:::\\ \\ /:::/\\:::\\ \\ /:::/\\:::\\ \\ /:::/\\:::\\ \\ \n",
57+
" \\:::\\ \\ /:::/__\\:::\\ \\ /:::/ / /:::/ / /:::/|::| | /:::/__\\:::\\ \\ /:::/____/ /:::/ \\:::\\ \\ /:::/ /::\\____\\ \\:::\\ \\ /:::/ \\:::\\ \\ /:::/ \\:::\\ \\ /:::/ / \\:::\\ \\ /:::/ \\:::\\ \\ /:::/ \\:::\\ \\ /:::/ /::\\____\\ /:::/|::| | /:::/__\\:::\\ \\ \\:::\\ \\ /:::/__\\:::\\ \\ /:::/__\\:::\\ \\ /:::/__\\:::\\ \\ \n",
58+
" /::::\\ \\ /::::\\ \\:::\\ \\ /:::/ / /:::/ / /:::/ |::| | /::::\\ \\:::\\ \\ /::::\\ \\ /:::/ / \\:::\\ \\ /:::/ /:::/ / /::::\\ \\ /:::/ / \\:::\\ \\ /:::/ \\:::\\ \\ /:::/ / /::::\\ \\ /:::/ \\:::\\ \\ /:::/ / \\:::\\ \\ /:::/ /:::/ / /:::/ |::| | /::::\\ \\:::\\ \\ /::::\\ \\ /::::\\ \\:::\\ \\ /::::\\ \\:::\\ \\ /::::\\ \\:::\\ \\ \n",
59+
" /::::::\\ \\ /::::::\\ \\:::\\ \\ /:::/ / /:::/ / /:::/ |::|___|______ /::::::\\ \\:::\\ \\ /::::::\\ \\ _____ /:::/____/ \\:::\\____\\ /:::/ /:::/ _/___ /::::::\\ \\ /:::/____/ \\:::\\____\\ /:::/ / \\:::\\ \\ /:::/ / _____ /::::::\\ \\ /:::/ / \\:::\\ \\ /:::/____/ \\:::\\____\\ /:::/ /:::/ _/___ /:::/ |::| | _____ /::::::\\ \\:::\\ \\ /::::::\\ \\ /::::::\\ \\:::\\ \\ /::::::\\ \\:::\\ \\ /::::::\\ \\:::\\ \\ \n",
60+
" /:::/\\:::\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/ / /:::/ / /:::/ |::::::::\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/\\:::\\ \\ /\\ \\ |:::| | |:::| | /:::/___/:::/ /\\ \\ /:::/\\:::\\ \\ |:::| | |:::| | /:::/ / \\:::\\ \\ /:::/____/ /\\ \\ /:::/\\:::\\ \\ /:::/ / \\:::\\ ___\\ |:::| | |:::| | /:::/___/:::/ /\\ \\ /:::/ |::| |/\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/\\:::\\ \\ /:::/\\:::\\ \\:::\\____\\ /:::/\\:::\\ \\:::\\ \\ /:::/\\:::\\ \\:::\\ \\ \n",
61+
" /:::/ \\:::\\____\\/:::/__\\:::\\ \\:::\\____\\/:::/____/ /:::/____/ /:::/ |:::::::::\\____\\/:::/__\\:::\\ \\:::\\____\\ /:::/ \\:::\\ /::\\____\\|:::|____| |:::| ||:::| /:::/ /::\\____\\ /:::/ \\:::\\____\\|:::|____| |:::| | /:::/____/ \\:::\\____\\|:::| / /::\\____\\ /:::/ \\:::\\____\\ /:::/____/ \\:::| ||:::|____| |:::| ||:::| /:::/ /::\\____\\/:: / |::| /::\\____\\ /:::/ \\:::\\ \\:::\\____\\ /:::/ \\:::\\____\\/:::/ \\:::\\ \\:::| |/:::/__\\:::\\ \\:::\\____\\/:::/__\\:::\\ \\:::\\____\\\n",
62+
" /:::/ \\::/ /\\:::\\ \\:::\\ \\::/ /\\:::\\ \\ \\:::\\ \\ \\::/ / ~~~~~/:::/ /\\:::\\ \\:::\\ \\::/ / \\::/ \\:::\\ /:::/ / \\:::\\ \\ /:::/ / |:::|__/:::/ /:::/ / /:::/ \\::/ / \\:::\\ \\ /:::/ / \\:::\\ \\ \\::/ /|:::|____\\ /:::/ / /:::/ \\::/ / \\:::\\ \\ /:::|____| \\:::\\ \\ /:::/ / |:::|__/:::/ /:::/ /\\::/ /|::| /:::/ / \\::/ \\:::\\ /:::/ / /:::/ \\::/ /\\::/ |::::\\ /:::|____|\\:::\\ \\:::\\ \\::/ /\\:::\\ \\:::\\ \\::/ /\n",
63+
" /:::/ / \\/____/ \\:::\\ \\:::\\ \\/____/ \\:::\\ \\ \\:::\\ \\ \\/____/ /:::/ / \\:::\\ \\:::\\ \\/____/ \\/____/ \\:::\\/:::/ / \\:::\\ \\ /:::/ / \\:::\\/:::/ /:::/ / /:::/ / \\/____/ \\:::\\ \\ /:::/ / \\:::\\ \\ \\/____/ \\:::\\ \\ /:::/ / /:::/ / \\/____/ \\:::\\ \\ /:::/ / \\:::\\ \\ /:::/ / \\:::\\/:::/ /:::/ / \\/____/ |::| /:::/ / \\/____/ \\:::\\/:::/ / /:::/ / \\/____/ \\/____|:::::\\/:::/ / \\:::\\ \\:::\\ \\/____/ \\:::\\ \\:::\\ \\/____/ \n",
64+
" /:::/ / \\:::\\ \\:::\\ \\ \\:::\\ \\ \\:::\\ \\ /:::/ / \\:::\\ \\:::\\ \\ \\::::::/ / \\:::\\ /:::/ / \\::::::/ /:::/ / /:::/ / \\:::\\ /:::/ / \\:::\\ \\ \\:::\\ \\ /:::/ / /:::/ / \\:::\\ \\ /:::/ / \\:::\\ /:::/ / \\::::::/ /:::/ / |::|/:::/ / \\::::::/ / /:::/ / |:::::::::/ / \\:::\\ \\:::\\ \\ \\:::\\ \\:::\\ \\ \n",
65+
"/:::/ / \\:::\\ \\:::\\____\\ \\:::\\ \\ \\:::\\ \\ /:::/ / \\:::\\ \\:::\\____\\ \\::::/ / \\:::\\__/:::/ / \\::::/___/:::/ / /:::/ / \\:::\\__/:::/ / \\:::\\ \\ \\:::\\ /:::/ / /:::/ / \\:::\\ /:::/ / \\:::\\__/:::/ / \\::::/___/:::/ / |::::::/ / \\::::/ / /:::/ / |::|\\::::/ / \\:::\\ \\:::\\____\\ \\:::\\ \\:::\\____\\ \n",
66+
"\\::/ / \\:::\\ \\::/ / \\:::\\ \\ \\:::\\ \\ /:::/ / \\:::\\ \\::/ / /:::/ / \\::::::::/ / \\:::\\__/:::/ / \\::/ / \\::::::::/ / \\:::\\ \\ \\:::\\__/:::/ / \\::/ / \\:::\\ /:::/ / \\::::::::/ / \\:::\\__/:::/ / |:::::/ / /:::/ / \\::/ / |::| \\::/____/ \\:::\\ \\::/ / \\:::\\ \\::/ / \n",
67+
" \\/____/ \\:::\\ \\/____/ \\:::\\ \\ \\:::\\ \\ /:::/ / \\:::\\ \\/____/ /:::/ / \\::::::/ / \\::::::::/ / \\/____/ \\::::::/ / \\:::\\ \\ \\::::::::/ / \\/____/ \\:::\\/:::/ / \\::::::/ / \\::::::::/ / |::::/ / /:::/ / \\/____/ |::| ~| \\:::\\ \\/____/ \\:::\\ \\/____/ \n",
68+
" \\:::\\ \\ \\:::\\ \\ \\:::\\ \\ /:::/ / \\:::\\ \\ /:::/ / \\::::/ / \\::::::/ / \\::::/ / \\:::\\ \\ \\::::::/ / \\::::::/ / \\::::/ / \\::::::/ / /:::/ / /:::/ / |::| | \\:::\\ \\ \\:::\\ \\ \n",
69+
" \\:::\\____\\ \\:::\\____\\ \\:::\\____\\ /:::/ / \\:::\\____\\ /:::/ / \\::/____/ \\::::/ / \\::/____/ \\:::\\____\\ \\::::/ / \\::::/ / \\::/____/ \\::::/ / /:::/ / /:::/ / \\::| | \\:::\\____\\ \\:::\\____\\ \n",
70+
" \\::/ / \\::/ / \\::/ / \\::/ / \\::/ / \\::/ / ~~ \\::/____/ ~~ \\::/ / \\::/____/ \\::/____/ ~~ \\::/____/ \\::/ / \\::/ / \\:| | \\::/ / \\::/ / \n",
71+
" \\/____/ \\/____/ \\/____/ \\/____/ \\/____/ \\/____/ ~~ \\/____/ ~~ ~~ ~~ \\/____/ \\/____/ \\|___| \\/____/ \\/____/ \n",
72+
" \n",
6173
"\n",
62-
"text: 0000000001110100 0000000001100101 0000000001101100 0000000001101100 0000000000100000 0000000001101101 0000000001100101 0000000000100000 0000000001101000 0000000001101111 0000000001110111 0000000000100000 0000000001110100 0000000001101111 0000000000100000 0000000001100011 0000000001110101 0000000001110100 0000000000100000 0000000001100100 0000000001101111 0000000001110111 0000000001101110 0000000000100000 0000000001100001 0000000000100000 0000000001110100 0000000001110010 0000000001100101 0000000001100101\n"
74+
"text: 0000000001110100 0000000001100101 0000000001101100 0000000001101100 0000000000100000 0000000001101101 0000000001100101 0000000000100000 0000000001101000 0000000001101111 0000000001110111 0000000000100000 0000000001110100 0000000001101111 0000000000100000 0000000001100011 0000000001110101 0000000001110100 0000000000100000 0000000001100100 0000000001101111 0000000001110111 0000000001101110 0000000000100000 0000000001100001 0000000000100000 0000000001110100 0000000001110010 0000000001100101 0000000001100101\n",
75+
"text: t m h t c d a t\n"
6376
]
6477
}
6578
],
@@ -68,6 +81,7 @@
6881
"from pyrit.prompt_converter import (\n",
6982
" AsciiArtConverter,\n",
7083
" BinaryConverter,\n",
84+
" FirstLetterConverter,\n",
7185
" RandomCapitalLettersConverter,\n",
7286
" ROT13Converter,\n",
7387
")\n",
@@ -80,7 +94,8 @@
8094
"print(await ROT13Converter().convert_tokens_async(prompt=prompt)) # type: ignore\n",
8195
"print(await RandomCapitalLettersConverter(percentage=25.0).convert_tokens_async(prompt=prompt)) # type: ignore\n",
8296
"print(await AsciiArtConverter().convert_tokens_async(prompt=prompt)) # type: ignore\n",
83-
"print(await BinaryConverter().convert_tokens_async(prompt=prompt)) # type: ignore"
97+
"print(await BinaryConverter().convert_tokens_async(prompt=prompt)) # type: ignore\n",
98+
"print(await FirstLetterConverter().convert_tokens_async(prompt=prompt)) # type: ignore"
8499
]
85100
},
86101
{
@@ -112,7 +127,7 @@
112127
"name": "python",
113128
"nbconvert_exporter": "python",
114129
"pygments_lexer": "ipython3",
115-
"version": "3.11.9"
130+
"version": "3.13.5"
116131
}
117132
},
118133
"nbformat": 4,

doc/code/converters/0_converters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# extension: .py
77
# format_name: percent
88
# format_version: '1.3'
9-
# jupytext_version: 1.16.4
9+
# jupytext_version: 1.17.2
1010
# kernelspec:
1111
# display_name: pyrit-dev
1212
# language: python
@@ -32,6 +32,7 @@
3232
from pyrit.prompt_converter import (
3333
AsciiArtConverter,
3434
BinaryConverter,
35+
FirstLetterConverter,
3536
RandomCapitalLettersConverter,
3637
ROT13Converter,
3738
)
@@ -45,6 +46,7 @@
4546
print(await RandomCapitalLettersConverter(percentage=25.0).convert_tokens_async(prompt=prompt)) # type: ignore
4647
print(await AsciiArtConverter().convert_tokens_async(prompt=prompt)) # type: ignore
4748
print(await BinaryConverter().convert_tokens_async(prompt=prompt)) # type: ignore
49+
print(await FirstLetterConverter().convert_tokens_async(prompt=prompt)) # type: ignore
4850

4951

5052
# %%

0 commit comments

Comments
 (0)