Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Listing Available Classes

Use get_names() to see what’s available, or list_metadata() for detailed information.

Available scenarios: ['airt.content_harms', 'airt.cyber', 'airt.scam', 'foundry.red_team_agent', 'garak.encoding']...

airt.content_harms:
  Class: ContentHarms
  Description: Content Harms Scenario implementation for PyRIT. This scenario contains various ...

airt.cyber:
  Class: Cyber
  Description: Cyber scenario implementation for PyRIT. This scenario tests how willing models ...

Getting a Class

Use get_class() to retrieve a class by name. This returns the class itself, not an instance.

Got class: <class 'pyrit.scenario.scenarios.garak.encoding.Encoding'>
Class name: Encoding

Creating Instances

Once you have a class, instantiate it with your parameters. You can also use create_instance() as a shortcut.

Found default environment files: ['./.pyrit/.env', './.pyrit/.env.local']
Loaded environment file: ./.pyrit/.env
Loaded environment file: ./.pyrit/.env.local

Loading datasets - this can take a few minutes:   0%|                                      | 0/45 [00:00<?, ?dataset/s]

Loading datasets - this can take a few minutes:   2%|▋                             | 1/45 [00:00<00:16,  2.70dataset/s]

Loading datasets - this can take a few minutes:  38%|██████████▉                  | 17/45 [00:00<00:00, 46.49dataset/s]

Loading datasets - this can take a few minutes:  69%|███████████████████▉         | 31/45 [00:00<00:00, 56.82dataset/s]

Loading datasets - this can take a few minutes: 100%|█████████████████████████████| 45/45 [00:00<00:00, 66.94dataset/s]

Scenarios can be instantiated with your target and parameters

Checking Registration

Registries support standard Python container operations.

'garak.encoding' registered: True
'nonexistent' registered: False
Total scenarios: 5
  - airt.content_harms
  - airt.cyber
  - airt.scam

Using different registries

There can be multiple registries. Below is doing a similar thing with the InitializerRegistry.

Available initializers: ['airt', 'load_default_datasets', 'objective_list', 'openai_objective_target', 'simple']...

airt:
  Class: AIRTInitializer
  Description: AI Red Team setup with Azure OpenAI converters, composite harm/objective scorers...

load_default_datasets:
  Class: LoadDefaultDatasets
  Description: This configuration uses the DatasetLoader to load default datasets into memory.
...