Repository navigation
feat(studio): Anonymizer Rewrite strategy params [ASTD-334] #904
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ecf3d1f
feat(studio): Rewrite strategy params [ASTD-334]
marcusds fbbd8ca
refactor(studio): hoist stable props out of anonymizer render path
marcusds a97ecb4
refactor(studio): decouple anonymizer role model defaults from the tab
marcusds f2f5ffe
refactor(studio): extract AnonymizerBuilderForm from the route
marcusds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
91 changes: 91 additions & 0 deletions
91
web/packages/studio/src/routes/AnonymizerBuilderRoute/components/RewriteParamsSection.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { ControlledCheckbox } from '@nemo/common/src/components/form/ControlledCheckbox'; | ||
| import { ControlledSegmentedControl } from '@nemo/common/src/components/form/ControlledSegmentedControl'; | ||
| import { ControlledTextArea } from '@nemo/common/src/components/form/ControlledTextArea'; | ||
| import { ControlledTextInput } from '@nemo/common/src/components/form/ControlledTextInput'; | ||
| import { FormField, Slider, Stack } from '@nvidia/foundations-react-core'; | ||
| import { | ||
| PRIVACY_GOAL_MODE_CUSTOM, | ||
| PRIVACY_GOAL_MODE_OPTIONS, | ||
| REWRITE_MIN_MAX_REPAIR_ROUNDS, | ||
| RISK_TOLERANCE_LABELS, | ||
| RISK_TOLERANCE_ORDER, | ||
| } from '@studio/routes/AnonymizerBuilderRoute/constants'; | ||
| import type { AnonymizerFormData } from '@studio/routes/AnonymizerBuilderRoute/schema'; | ||
| import { FC } from 'react'; | ||
| import { useController, useFormContext, useWatch } from 'react-hook-form'; | ||
|
|
||
| const formatRiskToleranceStep = (index: number) => | ||
| RISK_TOLERANCE_LABELS[RISK_TOLERANCE_ORDER[index]]; | ||
|
|
||
| export const RewriteParamsSection: FC = () => { | ||
| const { control } = useFormContext<AnonymizerFormData>(); | ||
| const privacyGoalMode = useWatch({ control, name: 'privacyGoalMode' }); | ||
| const { | ||
| field: { onChange: onRiskToleranceChange, value: riskTolerance }, | ||
| } = useController({ control, name: 'riskTolerance' }); | ||
|
|
||
| return ( | ||
| <Stack gap="density-lg"> | ||
| <FormField slotLabel="Privacy Goal"> | ||
| <ControlledSegmentedControl | ||
| className="w-full" | ||
| size="tiny" | ||
| items={PRIVACY_GOAL_MODE_OPTIONS} | ||
| useControllerProps={{ name: 'privacyGoalMode', control }} | ||
| /> | ||
| </FormField> | ||
| {privacyGoalMode === PRIVACY_GOAL_MODE_CUSTOM && ( | ||
| <> | ||
| <ControlledTextArea | ||
| useControllerProps={{ name: 'privacyProtect', control }} | ||
| formFieldProps={{ | ||
| slotLabel: 'Protect', | ||
| slotInfo: 'What to protect, such as direct and quasi-identifiers.', | ||
| }} | ||
| /> | ||
| <ControlledTextArea | ||
| useControllerProps={{ name: 'privacyPreserve', control }} | ||
| formFieldProps={{ | ||
| slotLabel: 'Preserve', | ||
| slotInfo: 'What to keep intact, such as utility and semantic meaning.', | ||
| }} | ||
| /> | ||
| </> | ||
| )} | ||
| <ControlledTextArea | ||
| useControllerProps={{ name: 'rewriteInstructions', control }} | ||
| formFieldProps={{ slotLabel: 'LLM Instructions' }} | ||
| /> | ||
| <FormField slotLabel="Risk Tolerance"> | ||
| <Slider | ||
| aria-label="Risk tolerance" | ||
| className="mb-5 px-6" | ||
| orientation="horizontal" | ||
| stepPosition="end" | ||
| min={0} | ||
| max={RISK_TOLERANCE_ORDER.length - 1} | ||
| step={1} | ||
| stepFormatFn={formatRiskToleranceStep} | ||
| value={RISK_TOLERANCE_ORDER.indexOf(riskTolerance)} | ||
| onValueChange={(index) => onRiskToleranceChange(RISK_TOLERANCE_ORDER[index])} | ||
| /> | ||
| </FormField> | ||
| <ControlledTextInput | ||
| type="number" | ||
| min={REWRITE_MIN_MAX_REPAIR_ROUNDS} | ||
| useControllerProps={{ name: 'maxRepairRounds', control }} | ||
| formFieldProps={{ | ||
| slotLabel: 'Max Repair Rounds', | ||
| slotInfo: 'Repair passes run when leakage exceeds the tolerance. Set to 0 to disable.', | ||
| }} | ||
| /> | ||
| <ControlledCheckbox | ||
| slotLabel="Strict Entity Protection. Forces every detected entity to be protected regardless of risk. No entity can be left unchanged." | ||
| useControllerProps={{ name: 'strictEntityProtection', control }} | ||
| /> | ||
| </Stack> | ||
| ); | ||
| }; |
11 changes: 11 additions & 0 deletions
11
web/packages/studio/src/routes/AnonymizerBuilderRoute/components/RoleModelDefaults.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { useDefaultRoleModels } from '@studio/routes/AnonymizerBuilderRoute/useDefaultRoleModels'; | ||
| import { FC } from 'react'; | ||
|
|
||
| /** Seeds role model defaults from inside the form provider, independent of the active tab. */ | ||
| export const RoleModelDefaults: FC = () => { | ||
| useDefaultRoleModels(); | ||
| return null; | ||
| }; | ||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.