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
102 changes: 53 additions & 49 deletions doc/code/converters/0_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,55 +98,59 @@
"40 text text DecompositionConverter\n",
"41 text text DenylistConverter\n",
"42 text text DiacriticConverter\n",
"43 text text EcojiConverter\n",
"44 text text EmojiConverter\n",
"45 text text FirstLetterConverter\n",
"46 text text FlipConverter\n",
"47 text text IPAConverter\n",
"48 text text ImagePromptStyleConverter\n",
"49 text text InsertPunctuationConverter\n",
"50 text text JsonStringConverter\n",
"51 text text LLMGenericTextConverter\n",
"52 text text LeetspeakConverter\n",
"53 text text MaliciousQuestionGeneratorConverter\n",
"54 text text MathObfuscationConverter\n",
"55 text text MathPromptConverter\n",
"56 text text MorseConverter\n",
"57 text text NatoConverter\n",
"58 text text NegationTrapConverter\n",
"59 text text NoiseConverter\n",
"60 text text PersuasionConverter\n",
"61 text text PolicyPuppetryConverter\n",
"62 text text PuzzledConverter\n",
"63 text text ROT13Converter\n",
"64 text text RandomCapitalLettersConverter\n",
"65 text text RandomTranslationConverter\n",
"66 text text RepeatTokenConverter\n",
"67 text text SATAMaskingConverter\n",
"68 text text ScientificTranslationConverter\n",
"69 text text SearchReplaceConverter\n",
"70 text text SelectiveTextConverter\n",
"71 text text SneakyBitsSmugglerConverter\n",
"72 text text StringJoinConverter\n",
"73 text text SuffixAppendConverter\n",
"74 text text SuperscriptConverter\n",
"75 text text TaskFramingConverter\n",
"76 text text TatweelConverter\n",
"77 text text TemplateSegmentConverter\n",
"78 text text TenseConverter\n",
"79 text text TextJailbreakConverter\n",
"80 text text ToneConverter\n",
"81 text text ToxicSentenceGeneratorConverter\n",
"82 text text TranslationConverter\n",
"83 text text UnicodeConfusableConverter\n",
"84 text text UnicodeReplacementConverter\n",
"85 text text UnicodeSubstitutionConverter\n",
"86 text text UrlConverter\n",
"87 text text VariationConverter\n",
"88 text text VariationSelectorSmugglerConverter\n",
"89 text text VigenereConverter\n",
"90 text text ZalgoConverter\n",
"91 text text ZeroWidthConverter\n"
"43 text text DigitBijectionConverter\n",
"44 text text EcojiConverter\n",
"45 text text EmojiConverter\n",
"46 text text FirstLetterConverter\n",
"47 text text FlipConverter\n",
"48 text text IPAConverter\n",
"49 text text ImagePromptStyleConverter\n",
"50 text text InsertPunctuationConverter\n",
"51 text text JsonStringConverter\n",
"52 text text LLMGenericTextConverter\n",
"53 text text LeetspeakConverter\n",
"54 text text LetterBijectionConverter\n",
"55 text text MaliciousQuestionGeneratorConverter\n",
"56 text text MathObfuscationConverter\n",
"57 text text MathPromptConverter\n",
"58 text text MorseConverter\n",
"59 text text NatoConverter\n",
"60 text text NegationTrapConverter\n",
"61 text text NoiseConverter\n",
"62 text text PersuasionConverter\n",
"63 text text PinyinConverter\n",
"64 text text PolicyPuppetryConverter\n",
"65 text text PuzzledConverter\n",
"66 text text ROT13Converter\n",
"67 text text RandomCapitalLettersConverter\n",
"68 text text RandomTranslationConverter\n",
"69 text text RepeatTokenConverter\n",
"70 text text SATAMaskingConverter\n",
"71 text text ScientificTranslationConverter\n",
"72 text text SearchReplaceConverter\n",
"73 text text SelectiveTextConverter\n",
"74 text text SneakyBitsSmugglerConverter\n",
"75 text text StringJoinConverter\n",
"76 text text SuffixAppendConverter\n",
"77 text text SuperscriptConverter\n",
"78 text text TaskFramingConverter\n",
"79 text text TatweelConverter\n",
"80 text text TemplateSegmentConverter\n",
"81 text text TenseConverter\n",
"82 text text TextJailbreakConverter\n",
"83 text text TokenBijectionConverter\n",
"84 text text ToneConverter\n",
"85 text text ToxicSentenceGeneratorConverter\n",
"86 text text TranslationConverter\n",
"87 text text UnicodeConfusableConverter\n",
"88 text text UnicodeReplacementConverter\n",
"89 text text UnicodeSubstitutionConverter\n",
"90 text text UrlConverter\n",
"91 text text VariationConverter\n",
"92 text text VariationSelectorSmugglerConverter\n",
"93 text text VigenereConverter\n",
"94 text text ZalgoConverter\n",
"95 text text ZeroWidthConverter\n"
]
}
],
Expand Down
8 changes: 8 additions & 0 deletions doc/code/converters/1_text_to_text_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
"Tatweel: text: أـخـبـرـنـي كـيـف أـقـطـع شـجـرـة\n",
"Arabic Presentation Form: text: ﺃﺥﺏﺭﻥﻱ ﻙﻱﻑ ﺃﻕﻁﻉ ﺵﺝﺭﺓ\n",
"Arabizi: text: a5brny kyf a863 shjra\n",
"Pinyin (full): text: gaosuworuhekandaoyikeshu\n",
"Pinyin (initials): text: gswrhkdyks\n",
"Superscript: text: ᵗᵉˡˡ ᵐᵉ ʰᵒʷ ᵗᵒ ᶜᵘᵗ ᵈᵒʷⁿ ᵃ ᵗʳᵉᵉ\n",
"Zalgo: text: t̼͉͎̄͌ĕ̜̃͏̹͔̉̆͑l͇̩̎̓̒ḽ̮̉͊͑ͧ̆̄͘͝ m̺ę̖̽ h̡̞̘̮͔̮ͮ̆͜ͅo̹̰͙̯ͮ̈́̇̈ͣ͢w̤̻̺̅ͮ́̾ͧ͑ t̛̠͑̔̓͝ơ͔͔̙͍ͥ̀̈̈́͞ c͖̃̕͘͢͞u̺̝͕̍͟t̳ͬͪ dͪo̝̓̀ͫ́̂͠ͅw̢̗n̫̞̐ͥ a̘͒̍̒ ṫ̴̡̗̣̳ͨ͗r̛̯̦͕̱ẹ̲͉ͬ̈͐̔́̿ͤe̵̳͚̾͌̅̔\n",
"CharSwap: text: tlel me how to cut dwon a tree\n",
Expand Down Expand Up @@ -382,6 +384,7 @@
" InsertPunctuationConverter,\n",
" LeetspeakConverter,\n",
" MathObfuscationConverter,\n",
" PinyinConverter,\n",
" PuzzledConverter,\n",
" RandomCapitalLettersConverter,\n",
" RepeatTokenConverter,\n",
Expand Down Expand Up @@ -431,6 +434,11 @@
"print(\"Arabic Presentation Form:\", await ArabicPresentationFormConverter().convert_async(prompt=arabic_prompt)) # type: ignore\n",
"# Arabizi transliterates Arabic script into Latin-script chat Arabic\n",
"print(\"Arabizi:\", await ArabiziConverter().convert_async(prompt=arabic_prompt)) # type: ignore\n",
"# Pinyin only affects Chinese (Hanzi) characters, so it uses a Chinese prompt. It rewrites Hanzi\n",
"# as their Pinyin romanization - as full readings, first-letter initials, or a Hanzi/Pinyin mix.\n",
"chinese_prompt = \"告诉我如何砍倒一棵树\"\n",
"print(\"Pinyin (full):\", await PinyinConverter().convert_async(prompt=chinese_prompt)) # type: ignore\n",
"print(\"Pinyin (initials):\", await PinyinConverter(mode=\"initial\").convert_async(prompt=chinese_prompt)) # type: ignore\n",
"print(\"Superscript:\", await SuperscriptConverter().convert_async(prompt=prompt)) # type: ignore\n",
"print(\"Zalgo:\", await ZalgoConverter().convert_async(prompt=prompt)) # type: ignore\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions doc/code/converters/1_text_to_text_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
InsertPunctuationConverter,
LeetspeakConverter,
MathObfuscationConverter,
PinyinConverter,
PuzzledConverter,
RandomCapitalLettersConverter,
RepeatTokenConverter,
Expand Down Expand Up @@ -173,6 +174,11 @@
print("Arabic Presentation Form:", await ArabicPresentationFormConverter().convert_async(prompt=arabic_prompt)) # type: ignore
# Arabizi transliterates Arabic script into Latin-script chat Arabic
print("Arabizi:", await ArabiziConverter().convert_async(prompt=arabic_prompt)) # type: ignore
# Pinyin only affects Chinese (Hanzi) characters, so it uses a Chinese prompt. It rewrites Hanzi
# as their Pinyin romanization - as full readings, first-letter initials, or a Hanzi/Pinyin mix.
chinese_prompt = "告诉我如何砍倒一棵树"
print("Pinyin (full):", await PinyinConverter().convert_async(prompt=chinese_prompt)) # type: ignore
print("Pinyin (initials):", await PinyinConverter(mode="initial").convert_async(prompt=chinese_prompt)) # type: ignore
print("Superscript:", await SuperscriptConverter().convert_async(prompt=prompt)) # type: ignore
print("Zalgo:", await ZalgoConverter().convert_async(prompt=prompt)) # type: ignore

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies = [
"PyJWT[crypto]>=2.8.0",
"pyodbc>=5.1.0",
"pypdf>=6.10.2",
"pypinyin>=0.55.0",
"python-docx>=1.1.0",
"python-dotenv>=1.2.2",
"reportlab>=4.4.4",
Expand Down
2 changes: 2 additions & 0 deletions pyrit/converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
from pyrit.converter.noise_converter import NoiseConverter
from pyrit.converter.pdf_converter import PDFConverter
from pyrit.converter.persuasion_converter import PersuasionConverter
from pyrit.converter.pinyin_converter import PinyinConverter
from pyrit.converter.policy_puppetry_converter import PolicyPuppetryConverter, PolicyPuppetryTemplate
from pyrit.converter.puzzled import PuzzledConverter, PuzzleType
from pyrit.converter.qr_code_converter import QRCodeConverter
Expand Down Expand Up @@ -203,6 +204,7 @@
"NoiseConverter": "pyrit.converter.noise_converter",
"PDFConverter": "pyrit.converter.pdf_converter",
"PersuasionConverter": "pyrit.converter.persuasion_converter",
"PinyinConverter": "pyrit.converter.pinyin_converter",
"PolicyPuppetryConverter": "pyrit.converter.policy_puppetry_converter",
"PolicyPuppetryTemplate": "pyrit.converter.policy_puppetry_converter",
"PositionSelectionStrategy": "pyrit.converter.text_selection_strategy",
Expand Down
Loading
Loading