Skip to content

Adding _InternalRiskCategory.ECI, RiskCategory.ProtectedMaterial, and RiskCategory.CodeVulnerability #41077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 18, 2025

Conversation

slister1001
Copy link
Member

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added the Evaluation Issues related to the client library for Azure AI Evaluation label May 14, 2025
@slister1001 slister1001 changed the title Adding RiskCategory.ECI, RiskCategory.ProtectedMaterial, and RiskCategory.CodeVulnerability Adding _InternalRiskCategory.ECI, RiskCategory.ProtectedMaterial, and RiskCategory.CodeVulnerability May 15, 2025
@slister1001 slister1001 marked this pull request as ready for review May 16, 2025 01:25
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 01:25
@slister1001 slister1001 requested a review from a team as a code owner May 16, 2025 01:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds three new risk categories (_InternalRiskCategory.ECI, RiskCategory.ProtectedMaterial, and RiskCategory.CodeVulnerability) to the red-team flow, updates client operations to accept both risk_type and risk_categories, and adjusts formatting and tests to reflect these additions.

  • Extend the RiskCategory enum and introduce _InternalRiskCategory.ECI
  • Update the autogenerated client and ONEDP operations to support risk_type/risk_categories
  • Adjust scorecard formatting and clean up deprecated evaluator mapping and related tests

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/evaluation/azure-ai-evaluation/tests/unittests/test_redteam/test_red_team.py Removed patch decorator without updating test signature
sdk/evaluation/azure-ai-evaluation/tests/unittests/test_redteam/test_constants.py Deleted tests for RISK_CATEGORY_EVALUATOR_MAP
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/simulator/_model_tools/_generated_rai_client.py Added risk_type and risk_categories params and updated calls
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_utils/metric_mapping.py Mapped new risk categories to evaluation metrics
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_utils/formatting_utils.py Increased column width for scorecard
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_utils/constants.py Removed the old RISK_CATEGORY_EVALUATOR_MAP constant
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_red_team.py Integrated new risk categories into objective retrieval & evaluation
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_attack_objective_generator.py Added ProtectedMaterial, CodeVulnerability, and _InternalRiskCategory.ECI
sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/raiclient/operations/_operations.py Introduced risk_categories param but mis-mapped risk_types
Comments suppressed due to low confidence (4)

sdk/evaluation/azure-ai-evaluation/tests/unittests/test_redteam/test_red_team.py:867

  • The test signature includes mock_risk_category_map but the corresponding patch decorator was removed, causing a mismatch. Either remove the unused parameter or re-add the patch decorator.
async def test_evaluate_method(self, mock_get_logger, mock_risk_category_map, red_team):

sdk/evaluation/azure-ai-evaluation/tests/unittests/test_redteam/test_constants.py:43

  • The tests for RISK_CATEGORY_EVALUATOR_MAP were removed, leaving no coverage for the evaluator mapping. Add tests to verify the new metric and risk category mappings.
def test_task_status_constants(self):

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_red_team.py:1596

  • The query field is set to the literal "query" despite the comment stating it should be empty. Restore it to an empty string to meet the API requirement.
"query": "query",  # Empty query as required

sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/red_team/_red_team.py:2022

  • The default risk categories list excludes the newly added ProtectedMaterial and CodeVulnerability. Include these new categories or revert to using list(RiskCategory).
self.attack_objective_generator.risk_categories = [RiskCategory.HateUnfairness, RiskCategory.Sexual, RiskCategory.Violence, RiskCategory.SelfHarm]

@slister1001 slister1001 merged commit d66a7b0 into Azure:main Jun 18, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Evaluation Issues related to the client library for Azure AI Evaluation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants