feat: add RiskAssessment.load() for cross-session reuse#214
Open
frankentini wants to merge 1 commit intoconfident-ai:mainfrom
Open
feat: add RiskAssessment.load() for cross-session reuse#214frankentini wants to merge 1 commit intoconfident-ai:mainfrom
frankentini wants to merge 1 commit intoconfident-ai:mainfrom
Conversation
Add a classmethod to deserialize saved risk assessments from JSON, enabling users to reload previous results and re-run attacks against improved models without regenerating test cases. The implementation: - Builds a reverse enum lookup across all VulnerabilityType enums to restore typed vulnerability_type fields from saved string values - Reconstructs RTTurn objects for multi-turn test cases - Falls back gracefully for custom vulnerability types - Includes comprehensive tests covering roundtrip save/load, multi-turn cases, multiple vulnerability types, and error handling Closes confident-ai#200
|
@frankentini is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
RiskAssessment.load(path)classmethod that deserializes JSON files produced byRiskAssessment.save(), enabling users to reload previous risk assessment results across Python sessions.This addresses the core ask in #200 — save/load for iterative red-teaming workflows where you want to generate attacks once and re-run them against improved model versions.
What it does
RiskAssessment.load(path)— reads a saved JSON file and reconstructs a fully typedRiskAssessmentinstanceVulnerabilityTypeenum classes to map serialized string values (e.g."gender") back to their proper enum members (e.g.BiasType.GENDER)RTTurnobjects for multi-turn test casesUsage
Tests
Added comprehensive test suite covering:
Closes #200