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.

Why Instance Registries?

Some components need configuration that can’t easily be passed at instantiation time. For example, scorers often need:

  • A configured chat_target for LLM-based scoring

  • Specific prompt templates

  • Other dependencies

Instance registries let initializers register fully-configured instances that are ready to use.

Listing Available Instances

Use instances.get_names() to see registered instances, or instances.list_metadata() for details.

Found default environment files: ['./.pyrit/.env', './.pyrit/.env.local']
Loaded environment file: ./.pyrit/.env
Loaded environment file: ./.pyrit/.env.local
No new upgrade operations detected.
Registered scorers: ['SelfAskRefusalScorer::5f719b8e']

Getting an Instance

Use instances.get() to retrieve a pre-configured instance by name. The instance is ready to use immediately.

Retrieved scorer: <pyrit.score.true_false.self_ask_refusal_scorer.SelfAskRefusalScorer object at 0x00000244B3068140>
Scorer type: SelfAskRefusalScorer

Inspecting Metadata

Scorer metadata includes the scorer type and identifier for tracking.


SelfAskRefusalScorer::5f719b8e:
  Class: SelfAskRefusalScorer
  Type: true_false

  📊 Scorer Information
    ▸ Scorer Identifier
      • Scorer Type: SelfAskRefusalScorer
      • scorer_type: true_false
      • score_aggregator: OR_
      • model_name: gpt-4o-japan-nilfilter

    ▸ Performance Metrics
      Official evaluation has not been run yet for this specific configuration

Filtering

Use list_metadata() with include_filters and exclude_filters dictionaries to filter scorers by any metadata property. include_filters requires ALL criteria to match (AND logic). exclude_filters excludes items matching ANY criteria. Filters use exact match for simple types and membership check for list types.

True/False scorers: ['SelfAskRefusalScorer::5f719b8e']
Refusal scorers: ['SelfAskRefusalScorer::5f719b8e']
True/False refusal scorers: ['SelfAskRefusalScorer::5f719b8e']

Using Target Initializer

You can optionally use the TargetInitializer to automatically configure and register targets that use commonly used environment variables (from .env_example). This initializer does not strictly require any environment variables - it simply registers whatever endpoints are available.

Found default environment files: ['./.pyrit/.env', './.pyrit/.env.local']
Loaded environment file: ./.pyrit/.env
Loaded environment file: ./.pyrit/.env.local
Registered targets after initialization: ['adversarial_chat', 'azure_content_safety', 'azure_foundry_deepseek', 'azure_foundry_mistral_large', 'azure_foundry_phi4', 'azure_gpt4o_unsafe_chat', 'azure_gpt4o_unsafe_chat2', 'azure_gpt4o_unsafe_chat_temp9', 'azure_ml_phi', 'azure_openai_gpt35_chat', 'azure_openai_gpt4_chat', 'azure_openai_gpt4o', 'azure_openai_gpt4o_temp9', 'azure_openai_gpt5_1', 'azure_openai_gpt5_4', 'azure_openai_gpt5_responses', 'azure_openai_gpt5_responses_high_reasoning', 'azure_openai_integration_test', 'azure_openai_realtime', 'azure_openai_responses', 'azure_openai_video', 'google_gemini', 'ollama', 'openai_chat', 'openai_completion', 'openai_image_platform', 'openai_tts_azure', 'openai_tts_platform', 'platform_openai_chat', 'platform_openai_responses']