API Reference#

pyrit.analytics#

Analytics module for PyRIT conversation and result analysis.

analyze_results

Analyze a list of AttackResult objects and return overall and grouped statistics.

AttackStats

Statistics for attack analysis results.

ConversationAnalytics

Handles analytics operations on conversation data, such as finding similar chat messages based on conversation history or embedding similarity.

pyrit.auth#

Authentication functionality for a variety of services.

Authenticator

Abstract base class for authenticators.

AzureAuth

Azure CLI Authentication.

AzureStorageAuth

A utility class for Azure Storage authentication, providing methods to generate SAS tokens using user delegation keys.

pyrit.auxiliary_attacks#

pyrit.chat_message_normalizer#

Functionality to normalize chat messages into compatible formats for targets.

ChatMessageNormalizer

Abstract base class for normalizing chat messages for model or target compatibility.

ChatMessageNop

A no-op chat message normalizer that does not modify the input messages.

GenericSystemSquash

Normalizer that combines the first system message with the first user message using generic instruction tags.

ChatMessageNormalizerChatML

A chat message normalizer that converts a list of chat messages to a ChatML string.

ChatMessageNormalizerTokenizerTemplate

Enable application of the chat template stored in a Hugging Face tokenizer to a list of chat messages.

pyrit.cli#

Module to provide command-line interface functionalities for PyRIT. The CLI module is currently experimental.

pyrit.common#

Common utilities and helpers for PyRIT.

apply_defaults

Apply default values to a class constructor.

apply_defaults_to_method

Apply default values to a method's parameters.

combine_dict

Combine two dictionaries containing string keys and values into one.

combine_list

Combine two lists or strings into a single list with unique values.

convert_local_image_to_data_url

Convert a local image file to a data URL encoded in base64.

DefaultValueScope

Represents a scope for default values with class type, parameter name, and inheritance rules.

deprecation_message

Generate a deprecation message string.

display_image_response

Display response images if running in notebook environment.

download_chunk

Download a chunk of the file with a specified byte range.

download_file

Download a file in multiple segments (splits) using byte-range requests.

download_files

Download multiple files with parallel downloads and segmented downloading.

download_specific_files

Download specific files from a Hugging Face model repository.

get_available_files

Fetch available files for a model from the Hugging Face repository.

get_global_default_values

Get the global default values registry.

get_httpx_client

Get the httpx client for making requests.

get_kwarg_param

Validate and extract a parameter from kwargs.

get_non_required_value

Get a non-required value from an environment variable or a passed value, preferring the passed value.

get_random_indices

Generate a list of random indices based on the specified proportion of a given size.

get_required_value

Get a required value from an environment variable or a passed value, preferring the passed value.

is_in_ipython_session

Determine if the code is running in an IPython session.

make_request_and_raise_if_error_async

Make a request and raise an exception if it fails.

print_chat_messages_with_color

Print chat messages with color to console.

reset_default_values

Reset all default values in the global registry.

set_default_value

Set a default value for a specific class and parameter.

Singleton

A metaclass for creating singleton classes.

warn_if_set

Warn about unused parameters in configurations.

YamlLoadable

Abstract base class for objects that can be loaded from YAML files.

pyrit.datasets#

Dataset fetching and loading utilities for various red teaming and safety evaluation datasets.

SeedDatasetProvider

Abstract base class for providing seed datasets with automatic registration.

TextJailBreak

A class that manages jailbreak datasets (like DAN, etc.).

pyrit.embedding#

Embedding module for PyRIT to provide OpenAI text embedding class.

OpenAITextEmbedding

Text embedding class that works with both Azure OpenAI and platform OpenAI endpoints.

pyrit.exceptions#

BadRequestException

Exception class for bad client requests.

EmptyResponseException

Exception class for empty response errors.

handle_bad_request_exception

InvalidJsonException

Exception class for blocked content errors.

MissingPromptPlaceholderException

Exception class for missing prompt placeholder errors.

PyritException

pyrit_custom_result_retry

A decorator to apply retry logic with exponential backoff to a function.

pyrit_json_retry

A decorator to apply retry logic to a function.

pyrit_target_retry

A decorator to apply retry logic with exponential backoff to a function.

pyrit_placeholder_retry

A decorator to apply retry logic.

RateLimitException

Exception class for authentication errors.

remove_markdown_json

Checks if the response message is in JSON format and removes Markdown formatting if present.

pyrit.executor.attack#

Attack executor module.

AttackAdversarialConfig

Adversarial configuration for attacks that involve adversarial chat targets.

AttackContext

Base class for all attack contexts.

AttackConverterConfig

Configuration for prompt converters used in attacks.

AttackExecutor

Manages the execution of attack strategies with support for parallel execution.

AttackExecutorResult

Result container for attack execution, supporting both full and partial completion.

AttackParameters

Immutable parameters for attack execution.

AttackResultPrinter

Abstract base class for printing attack results.

AttackScoringConfig

Scoring configuration for evaluating attack effectiveness.

AttackStrategy

Abstract base class for attack strategies.

ConsoleAttackResultPrinter

Console printer for attack results with enhanced formatting.

ContextComplianceAttack

Implementation of the context compliance attack strategy.

ConversationManager

Manages conversations for attacks, handling message history, system prompts, and conversation state.

ConversationSession

Session for conversations.

ConversationState

Container for conversation state data shared between attack components.

CrescendoAttack

Implementation of the Crescendo attack strategy.

CrescendoAttackContext

Context for the Crescendo attack strategy.

CrescendoAttackResult

Result of the Crescendo attack strategy execution.

FlipAttack

Implement the FlipAttack method found here: https://arxiv.org/html/2410.02832v1.

ManyShotJailbreakAttack

Implement the Many Shot Jailbreak method as discussed in research found here: https://www.anthropic.com/research/many-shot-jailbreaking.

MarkdownAttackResultPrinter

Markdown printer for attack results optimized for Jupyter notebooks.

MultiPromptSendingAttack

Implementation of multi-prompt sending attack strategy.

MultiPromptSendingAttackParameters

Parameters for MultiPromptSendingAttack.

MultiTurnAttackContext

Context for multi-turn attacks.

MultiTurnAttackStrategy

Strategy for executing multi-turn attacks.

ObjectiveEvaluator

Evaluates scores from a Scorer to determine objective achievement and provide feedback.

PromptSendingAttack

Implementation of single-turn prompt sending attack strategy.

RTASystemPromptPaths

Enum for predefined red teaming attack system prompt paths.

RedTeamingAttack

Implementation of multi-turn red teaming attack strategy.

RolePlayAttack

Implementation of single-turn role-play attack strategy.

RolePlayPaths

Enum for predefined role-play scenario paths.

SingleTurnAttackContext

Context for single-turn attacks.

SingleTurnAttackStrategy

Strategy for executing single-turn attacks.

SkeletonKeyAttack

Implementation of the skeleton key jailbreak attack strategy.

TAPAttack

alias of TreeOfAttacksWithPruningAttack

TAPAttackContext

Context for the Tree of Attacks with Pruning (TAP) attack strategy.

TAPAttackResult

Result of the Tree of Attacks with Pruning (TAP) attack strategy execution.

TreeOfAttacksWithPruningAttack

Implement the Tree of Attacks with Pruning (TAP) attack strategy.

pyrit.executor.promptgen#

Prompt generator strategy imports.

AnecdoctorContext

Context specific to Anecdoctor prompt generation.

AnecdoctorGenerator

Implementation of the Anecdoctor prompt generation strategy.

AnecdoctorResult

Result of Anecdoctor prompt generation.

PromptGeneratorStrategy

Base class for all prompt generator strategies.

PromptGeneratorStrategyContext

Base class for all prompt generator strategy contexts.

PromptGeneratorStrategyResult

Base class for all prompt generator strategy results.

pyrit.executor.promptgen.fuzzer#

Fuzzer module for generating adversarial prompts through mutation and crossover operations.

FuzzerConverter

Base class for GPTFUZZER converters.

FuzzerContext

Context for the Fuzzer prompt generation strategy.

FuzzerCrossOverConverter

Uses multiple prompt templates to generate new prompts.

FuzzerExpandConverter

Generates versions of a prompt with new, prepended sentences.

FuzzerGenerator

Implementation of the Fuzzer prompt generation strategy using Monte Carlo Tree Search (MCTS).

FuzzerRephraseConverter

Generates versions of a prompt with rephrased sentences.

FuzzerResult

Result of the Fuzzer prompt generation strategy execution.

FuzzerResultPrinter

Printer for Fuzzer generation strategy results with enhanced console formatting.

FuzzerShortenConverter

Generates versions of a prompt with shortened sentences.

FuzzerSimilarConverter

Generates versions of a prompt with similar sentences.

pyrit.executor.workflow#

Workflow components and strategies used by the PyRIT executor.

XPIAContext

Context for Cross-Domain Prompt Injection Attack (XPIA) workflow.

XPIAResult

Result of XPIA workflow execution.

XPIAWorkflow

Implementation of Cross-Domain Prompt Injection Attack (XPIA) workflow.

XPIATestWorkflow

XPIA workflow with automated test processing.

XPIAManualProcessingWorkflow

XPIA workflow with manual processing intervention.

XPIAProcessingCallback

Protocol for processing callback functions used in XPIA workflows.

XPIAStatus

Enumeration of possible XPIA attack result statuses.

pyrit.memory#

Provide functionality for storing and retrieving conversation history and embeddings.

This package defines the core MemoryInterface and concrete implementations for different storage backends.

AttackResultEntry

Represents the attack result data in the database.

AzureSQLMemory

A class to manage conversation memory using Azure SQL Server as the backend database.

CentralMemory

Provide a centralized memory instance across the framework.

EmbeddingDataEntry

Represents the embedding data associated with conversation entries in the database.

MemoryInterface

Abstract interface for conversation memory storage systems.

MemoryEmbedding

The MemoryEmbedding class is responsible for encoding the memory embeddings.

MemoryExporter

Handles the export of data to various formats, currently supporting only JSON format.

PromptMemoryEntry

Represents the prompt data.

SeedEntry

Represents the raw prompt or prompt template data as found in open datasets.

SQLiteMemory

A memory interface that uses SQLite as the backend database.

pyrit.models#

ALLOWED_CHAT_MESSAGE_ROLES

Built-in mutable sequence.

AudioPathDataTypeSerializer

AzureBlobStorageIO

Implementation of StorageIO for Azure Blob Storage.

ChatMessage

ChatMessagesDataset

Represents a dataset of chat messages.

ChatMessageRole

alias of Literal['system', 'user', 'assistant', 'tool', 'developer']

ChatMessageListDictContent

construct_response_from_request

Constructs a response entry from a request.

ConversationReference

Immutable reference to a conversation that played a role in the attack.

ConversationType

Types of conversations that can be associated with an attack.

DataTypeSerializer

Abstract base class for data type normalizers.

data_serializer_factory

Factory method to create a DataTypeSerializer instance.

DiskStorageIO

Implementation of StorageIO for local disk storage.

EmbeddingData

EmbeddingResponse

EmbeddingSupport

EmbeddingUsageInformation

ErrorDataTypeSerializer

group_conversation_message_pieces_by_sequence

Groups message pieces from the same conversation into Messages.

group_message_pieces_into_conversations

Groups message pieces from multiple conversations into separate conversation groups.

Identifier

ImagePathDataTypeSerializer

AllowedCategories

alias of Literal['seed-prompt-entries', 'prompt-memory-entries']

AttackOutcome

Enum representing the possible outcomes of an attack.

AttackResult

Base class for all attack results.

Message

Represents a message in a conversation, for example a prompt or a response to a prompt.

MessagePiece

Represents a piece of a message to a target.

PromptDataType

alias of Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output']

PromptResponseError

alias of Literal['blocked', 'none', 'processing', 'empty', 'unknown']

QuestionAnsweringDataset

Represents a dataset for question answering.

QuestionAnsweringEntry

Represents a question model.

QuestionChoice

Represents a choice for a question.

ScenarioIdentifier

Scenario result class for aggregating results from multiple AtomicAttacks.

ScenarioResult

Scenario result class for aggregating scenario results.

Score

ScoreType

alias of Literal['true_false', 'float_scale']

Seed

Represents seed data with various attributes and metadata.

SeedDataset

SeedDataset manages seed prompts plus optional top-level defaults.

SeedGroup

A group of prompts that need to be sent together, along with an objective.

SeedObjective

Represents a seed objective with various attributes and metadata.

SeedPrompt

Represents a seed prompt with various attributes and metadata.

sort_message_pieces

Group by conversation_id.

StorageIO

Abstract interface for storage systems (local disk, Azure Storage Account, etc.).

StrategyResult

Base class for all strategy results.

TextDataTypeSerializer

UnvalidatedScore

Score is an object that validates all the fields.

pyrit.prompt_converter#

AddImageTextConverter

Adds a string to an image and wraps the text into multiple lines if necessary.

AddImageVideoConverter

Adds an image to a video at a specified position.

AddTextImageConverter

Adds a string to an image and wraps the text into multiple lines if necessary.

AnsiAttackConverter

Generates prompts with ANSI codes to evaluate LLM behavior and system risks.

AsciiArtConverter

Uses the art package to convert text into ASCII art.

AsciiSmugglerConverter

Implements encoding and decoding using Unicode Tags.

AskToDecodeConverter

Wraps encoded text with prompts that ask a target to decode it.

AtbashConverter

Encodes text using the Atbash cipher.

AudioFrequencyConverter

Shifts the frequency of an audio file by a specified value.

AzureSpeechAudioToTextConverter

Transcribes a .wav audio file into text using Azure AI Speech service.

AzureSpeechTextToAudioConverter

Generates a wave file from a text prompt using Azure AI Speech service.

Base2048Converter

Converter that encodes text to base2048 format.

Base64Converter

Converter that encodes text to base64 format.

BinAsciiConverter

Converts text to various binary-to-ASCII encodings.

BinaryConverter

Transforms input text into its binary representation with configurable bits per character (8, 16, or 32).

BrailleConverter

Converts text into Braille Unicode representation.

CaesarConverter

Encodes text using the Caesar cipher with a specified offset.

CharacterSpaceConverter

Spaces out the input prompt and removes specified punctuations.

CharSwapConverter

Applies character swapping to words in the prompt to test adversarial textual robustness.

CodeChameleonConverter

Encrypts user prompt, adds stringified decrypt function in markdown and instructions.

ColloquialWordswapConverter

Converts text into colloquial Singaporean context.

ConverterResult

The result of a prompt conversion, containing the converted output and its type.

DenylistConverter

Replaces forbidden words or phrases in a prompt with synonyms using an LLM.

DiacriticConverter

Applies diacritics to specified characters in a string.

EcojiConverter

Converter that encodes text using Ecoji encoding.

EmojiConverter

Converts English text to randomly chosen circle or square character emojis.

FirstLetterConverter

Replaces each word of the prompt with its first letter (or digit).

FlipConverter

Flips the input text prompt.

HumanInTheLoopConverter

Allows review of each prompt sent to a target before sending it.

ImageCompressionConverter

Compresses images to reduce file size while preserving visual quality.

IndexSelectionStrategy

Selects text based on absolute character indices.

InsertPunctuationConverter

Inserts punctuation into a prompt to test robustness.

KeywordSelectionStrategy

Selects text around a keyword with optional context.

LeetspeakConverter

Converts a string to a leetspeak version.

LLMGenericTextConverter

Represents a generic LLM converter that expects text to be transformed (e.g. no JSON parsing or format).

MaliciousQuestionGeneratorConverter

Generates malicious questions using an LLM.

MathObfuscationConverter

Convert text into character-level algebraic identities.

MathPromptConverter

Converts natural language instructions into symbolic mathematics problems using an LLM.

MorseConverter

Encodes prompts using morse code.

NatoConverter

Converts text into NATO phonetic alphabet representation.

NoiseConverter

Injects noise errors into a conversation using an LLM.

PDFConverter

Converts a text prompt into a PDF file.

PersuasionConverter

Rephrases prompts using a variety of persuasion techniques.

PositionSelectionStrategy

Selects text based on proportional start and end positions.

PromptConverter

Base class for converters that transform prompts into a different representation or format.

ProportionSelectionStrategy

Selects a proportion of text anchored to a specific position (start, end, middle, or random).

QRCodeConverter

Converts a text string to a QR code image.

RandomCapitalLettersConverter

Takes a prompt and randomly capitalizes it by a percentage of the total characters.

RandomTranslationConverter

Translates each individual word in a prompt to a random language using an LLM.

RangeSelectionStrategy

Selects text based on proportional start and end positions.

RegexSelectionStrategy

Selects text based on the first regex match.

RepeatTokenConverter

Repeats a specified token a specified number of times in addition to a given prompt.

ROT13Converter

Encodes prompts using the ROT13 cipher.

SearchReplaceConverter

Converts a string by replacing chosen phrase with a new phrase of choice.

SelectiveTextConverter

A wrapper converter that applies another converter to selected portions of text.

SneakyBitsSmugglerConverter

Encodes and decodes text using a bit-level approach.

StringJoinConverter

Converts text by joining its characters with the specified join value.

SuffixAppendConverter

Appends a specified suffix to the prompt.

SuperscriptConverter

Converts text to superscript.

TemplateSegmentConverter

Uses a template to randomly split a prompt into segments defined by the template.

TenseConverter

Converts a conversation to a different tense using an LLM.

TextJailbreakConverter

Uses a jailbreak template to create a prompt.

TextSelectionStrategy

Base class for text selection strategies used by SelectiveTextConverter and WordLevelConverter.

TokenSelectionStrategy

A special selection strategy that signals SelectiveTextConverter to auto-detect and convert text between start/end tokens (e.g., ⟪ and ⟫).

ToneConverter

Converts a conversation to a different tone using an LLM.

ToxicSentenceGeneratorConverter

Generates toxic sentence starters using an LLM.

TranslationConverter

Translates prompts into different languages using an LLM.

TransparencyAttackConverter

Creates a transparency attack by optimizing an alpha channel to blend attack and benign images.

UnicodeConfusableConverter

Applies substitutions to words in the prompt to test adversarial textual robustness by replacing characters with visually similar ones.

UnicodeReplacementConverter

Converts a prompt to its unicode representation.

UnicodeSubstitutionConverter

Encodes the prompt using any unicode starting point.

UrlConverter

Converts a prompt to a URL-encoded string.

VariationConverter

Generates variations of the input prompts using the converter target.

VariationSelectorSmugglerConverter

Encodes and decodes text using Unicode Variation Selectors.

WordIndexSelectionStrategy

Selects words based on their indices in the word list.

WordKeywordSelectionStrategy

Selects words that match specific keywords.

WordPositionSelectionStrategy

Selects words based on proportional start and end positions.

WordProportionSelectionStrategy

Selects a random proportion of words.

WordRegexSelectionStrategy

Selects words that match a regex pattern.

WordSelectionStrategy

Base class for word-level selection strategies.

ZalgoConverter

Converts text into cursed Zalgo text using combining Unicode marks.

ZeroWidthConverter

Injects zero-width spaces between characters in the provided text to bypass content safety mechanisms.

pyrit.prompt_normalizer#

Prompt normalization components for standardizing and converting prompts.

This module provides tools for normalizing prompts before sending them to targets, including converter configurations and request handling.

PromptNormalizer

Handles normalization and processing of prompts before they are sent to targets.

PromptConverterConfiguration

Represents the configuration for a prompt response converter.

NormalizerRequest

Represents a single request sent to normalizer.

pyrit.prompt_target#

Prompt targets for PyRIT.

Target implementations for interacting with different services and APIs, for example sending prompts or transferring content (uploads).

AzureBlobStorageTarget

The AzureBlobStorageTarget takes prompts, saves the prompts to a file, and stores them as a blob in a provided storage account container.

AzureMLChatTarget

A prompt target for Azure Machine Learning chat endpoints.

CopilotType

Enumeration of Copilot interface types.

CrucibleTarget

A prompt target for the Crucible service.

GandalfLevel

Enumeration of Gandalf challenge levels.

GandalfTarget

A prompt target for the Gandalf security challenge.

get_http_target_json_response_callback_function

Determine proper parsing response function for an HTTP Request.

get_http_target_regex_matching_callback_function

Get a callback function that parses HTTP responses using regex matching.

HTTPTarget

HTTP_Target is for endpoints that do not have an API and instead require HTTP request(s) to send a prompt.

HTTPXAPITarget

A subclass of HTTPTarget that only does "API mode" (no raw HTTP request).

HuggingFaceChatTarget

The HuggingFaceChatTarget interacts with HuggingFace models, specifically for conducting red teaming activities.

HuggingFaceEndpointTarget

The HuggingFaceEndpointTarget interacts with HuggingFace models hosted on cloud endpoints.

limit_requests_per_minute

Enforce rate limit of the target through setting requests per minute.

OpenAICompletionTarget

A prompt target for OpenAI completion endpoints.

OpenAIImageTarget

A target for image generation using OpenAI's image models.

OpenAIChatTarget

Facilitates multimodal (image and text) input and text output generation.

OpenAIResponseTarget

Enables communication with endpoints that support the OpenAI Response API.

OpenAIVideoTarget

OpenAI Video Target using the OpenAI SDK for video generation.

OpenAITTSTarget

A prompt target for OpenAI Text-to-Speech (TTS) endpoints.

OpenAITarget

Abstract base class for OpenAI-based prompt targets.

PlaywrightCopilotTarget

PlaywrightCopilotTarget uses Playwright to interact with Microsoft Copilot web UI.

PlaywrightTarget

PlaywrightTarget uses Playwright to interact with a web UI.

PromptChatTarget

A prompt chat target is a target where you can explicitly set the conversation history using memory.

PromptShieldTarget

PromptShield is an endpoint which detects the presence of a jailbreak.

PromptTarget

Abstract base class for prompt targets.

RealtimeTarget

A prompt target for Azure OpenAI Realtime API.

TextTarget

The TextTarget takes prompts, adds them to memory and writes them to io which is sys.stdout by default.

pyrit.score#

Scoring functionality for evaluating AI model responses across various dimensions including harm detection, objective completion, and content classification.

AzureContentFilterScorer

A scorer that uses Azure Content Safety API to evaluate text and images for harmful content.

BatchScorer

A utility class for scoring prompts in batches in a parallelizable and convenient way.

ContentClassifierPaths

Paths to content classifier YAML files.

ConversationScorer

Scorer that evaluates entire conversation history rather than individual messages.

create_conversation_scorer

Create a ConversationScorer that inherits from the same type as the wrapped scorer.

DecodingScorer

Scorer that checks if the request values are in the output using a text matching strategy.

FloatScaleScoreAggregator

Namespace for float scale score aggregators that return a single aggregated score.

FloatScaleScorer

Base class for scorers that return floating-point scores in the range [0, 1].

FloatScaleScorerAllCategories

Namespace for float scale score aggregators that combine all categories.

FloatScaleScorerByCategory

Namespace for float scale score aggregators that group by category.

FloatScaleThresholdScorer

A scorer that applies a threshold to a float scale score to make it a true/false score.

GandalfScorer

A scorer for evaluating responses in Gandalf challenges.

HarmHumanLabeledEntry

A class that represents a human-labeled dataset entry for a specific harm category.

HarmScorerEvaluator

A class that evaluates a harm scorer against HumanLabeledDatasets of type HARM.

HarmScorerMetrics

Metrics for evaluating a harm scorer against a HumanLabeledDataset.

HumanInTheLoopScorerGradio

Create scores from manual human input using Gradio and adds them to the database.

HumanLabeledDataset

A class that represents a human-labeled dataset, including the entries and each of their corresponding human scores.

HumanLabeledEntry

A class that represents an entry in a dataset of assistant responses that have been scored by humans.

InsecureCodeScorer

A scorer that uses an LLM to evaluate code snippets for potential security vulnerabilities.

LikertScalePaths

Enum containing paths to Likert scale YAML configuration files.

MarkdownInjectionScorer

A scorer that detects markdown injection attempts in text responses.

MetricsType

Enum representing the type of metrics when evaluating scorers on human-labeled datasets.

ObjectiveHumanLabeledEntry

A class that represents a human-labeled dataset entry for a specific objective.

ObjectiveScorerEvaluator

A class that evaluates an objective scorer against HumanLabeledDatasets of type OBJECTIVE.

ObjectiveScorerMetrics

Metrics for evaluating an objective scorer against a HumanLabeledDataset.

PlagiarismMetric

Enum representing different plagiarism detection metrics.

PlagiarismScorer

A scorer that measures plagiarism by computing word-level similarity between the AI response and a reference text.

PromptShieldScorer

Returns true if an attack or jailbreak has been detected by Prompt Shield.

QuestionAnswerScorer

A class that represents a question answering scorer.

Scorer

Abstract base class for scorers.

ScorerEvaluator

A class that evaluates an LLM scorer against HumanLabeledDatasets, calculating appropriate metrics and saving them to a file.

ScorerIdentifier

Configuration class for Scorers.

ScorerMetrics

Base dataclass for storing scorer evaluation metrics.

ScorerPromptValidator

Validates message pieces and scorer configurations.

SelfAskCategoryScorer

A class that represents a self-ask score for text classification and scoring.

SelfAskGeneralFloatScaleScorer

A general-purpose self-ask float-scale scorer that uses a chat target and a configurable system prompt and prompt format.

SelfAskGeneralTrueFalseScorer

A general-purpose self-ask True/False scorer that uses a chat target and a configurable system prompt and prompt format.

SelfAskLikertScorer

A class that represents a "self-ask" score for text scoring for a likert scale.

SelfAskQuestionAnswerScorer

A class that represents a self-ask question answering scorer.

SelfAskRefusalScorer

A self-ask scorer that detects refusal in AI responses.

SelfAskScaleScorer

A class that represents a "self-ask" score for text scoring for a customizable numeric scale.

SelfAskTrueFalseScorer

A class that represents a self-ask true/false for scoring.

SubStringScorer

Scorer that checks if a given substring is present in the text.

TrueFalseAggregatorFunc

alias of Callable[[Iterable[Score]], ScoreAggregatorResult]

TrueFalseCompositeScorer

Composite true/false scorer that aggregates results from other true/false scorers.

TrueFalseInverterScorer

A scorer that inverts a true false score.

TrueFalseQuestion

A class that represents a true/false question.

TrueFalseQuestionPaths

Paths to true/false question YAML files.

TrueFalseScoreAggregator

Namespace for true/false score aggregators that return a single aggregated score.

TrueFalseScorer

Base class for scorers that return true/false binary scores.

VideoFloatScaleScorer

A scorer that processes videos by extracting frames and scoring them using a float scale image scorer.

VideoTrueFalseScorer

A scorer that processes videos by extracting frames and scoring them using a true/false image scorer.

pyrit.scenario#

High-level scenario classes for running attack configurations.

AtomicAttack

Represents a single atomic attack test combining an attack strategy and dataset.

EncodingScenario

Encoding Scenario implementation for PyRIT.

FoundryStrategy

Strategies for attacks with tag-based categorization.

FoundryScenario

FoundryScenario is a preconfigured scenario that automatically generates multiple AtomicAttack instances based on the specified attack strategies.

Scenario

Groups and executes multiple AtomicAttack instances sequentially.

ScenarioStrategy

Base class for attack strategies with tag-based categorization and aggregation.

pyrit.setup#

Module containing initialization PyRIT.

initialize_pyrit_async

Initialize PyRIT with the provided memory instance and loads environment files.

AZURE_SQL

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

SQLITE

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

IN_MEMORY

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

pyrit.setup.initializers#

PyRIT initializers package.

PyRITInitializer

Abstract base class for PyRIT configuration initializers.

AIRTInitializer

AIRT (AI Red Team) configuration initializer.

SimpleInitializer

Complete simple configuration initializer.

LoadDefaultDatasets

Load default datasets for all registered scenarios.

ScenarioObjectiveListInitializer

Configure a default list of objectives for use in PyRIT scenarios.