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 get_names() to see registered instances, or list_metadata() for details.

Found default environment files: ['./.pyrit/.env']
Loaded environment file: ./.pyrit/.env
Registered scorers: ['self_ask_refusal_scorer::94a582f5']

Getting an Instance

Use 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 0x000001CB7FF57350>
Scorer type: SelfAskRefusalScorer

Inspecting Metadata

Scorer metadata includes the scorer type and identifier for tracking.


self_ask_refusal_scorer::94a582f5:
  Class: SelfAskRefusalScorer
  Type: true_false
  Description: A self-ask scorer that detects refusal in AI responses. This...

  📊 Scorer Information
    ▸ Scorer Identifier
      • Scorer Type: SelfAskRefusalScorer
      • Target Model: gpt-4o
      • Temperature: None
      • Score Aggregator: OR_

    ▸ 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: ['self_ask_refusal_scorer::94a582f5']
Refusal scorers: ['self_ask_refusal_scorer::94a582f5']
True/False refusal scorers: ['self_ask_refusal_scorer::94a582f5']

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']
Loaded environment file: ./.pyrit/.env
Registered targets after AIRT initialization: ['azure_content_safety', 'azure_gpt4o_unsafe_chat', 'azure_gpt4o_unsafe_chat2', 'default_openai_frontend', 'openai_chat', 'openai_image', 'openai_realtime', 'openai_responses', 'openai_tts', 'openai_video']