pyrit.score.AzureContentFilterScorer#
- class AzureContentFilterScorer(*, endpoint: str | None = None, api_key: str | None = None, use_entra_auth: bool = False, harm_categories: list[TextCategory] | None = None, validator: ScorerPromptValidator | None = None)[source]#
Bases:
FloatScaleScorerA scorer that uses Azure Content Safety API to evaluate text and images for harmful content.
This scorer analyzes content across multiple harm categories (hate, self-harm, sexual, violence) and returns a score for each category in the range [0, 1], where higher scores indicate more severe content. Supports both text and image inputs.
- __init__(*, endpoint: str | None = None, api_key: str | None = None, use_entra_auth: bool = False, harm_categories: list[TextCategory] | None = None, validator: ScorerPromptValidator | None = None) None[source]#
Class that initializes an Azure Content Filter Scorer
- Parameters:
api_key (str, Optional) – The API key for accessing the Azure OpenAI service (only if you’re not using Entra authentication). Defaults to the API_KEY_ENVIRONMENT_VARIABLE environment variable.
endpoint (str, Optional) – The endpoint URL for the Azure OpenAI service. Defaults to the ENDPOINT_URI_ENVIRONMENT_VARIABLE environment variable.
use_entra_auth (bool, Optional) – Whether to use Entra authentication. Defaults to False.
harm_categories – The harm categories you want to query for as per defined in azure.ai.contentsafety.models.TextCategory.
Methods
__init__(*[, endpoint, api_key, ...])Class that initializes an Azure Content Filter Scorer
get_identifier()Returns an identifier dictionary for the scorer.
get_scorer_metrics(dataset_name[, metrics_type])Returns evaluation statistics for the scorer using the dataset_name of the human labeled dataset that this scorer was run against.
scale_value_float(value, min_value, max_value)Scales a value from 0 to 1 based on the given min and max values.
score_async(message, *[, objective, ...])Score the message, add the results to the database and return a list of Score objects.
score_image_async(image_path, *[, objective])Scores the given image using the chat target.
score_image_batch_async(*, image_paths[, ...])score_prompts_batch_async(*, messages[, ...])Score multiple prompts in batches using the provided objectives.
score_response_async(*, response[, ...])Score a response using an objective scorer and optional auxiliary scorers.
score_response_multiple_scorers_async(*, ...)Score a response using multiple scorers in parallel.
score_text_async(text, *[, objective])Scores the given text based on the task using the chat target.
validate_return_scores(scores)Validates the scores returned by the scorer.
Attributes