mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
refactor(ui): build PII entity category map without mutation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
3445fb378f
commit
85d417effe
1 changed files with 6 additions and 10 deletions
|
|
@ -28,16 +28,12 @@ const PiiConfiguration: React.FC<PiiConfigurationProps> = ({
|
|||
? [...entityCategories, { category: "Custom", entities: customEntities }]
|
||||
: entityCategories;
|
||||
|
||||
// Create a lookup map to quickly find an entity's category
|
||||
const entityToCategoryMap = new Map<string, string>();
|
||||
entityCategories.forEach((category) => {
|
||||
category.entities.forEach((entity) => {
|
||||
entityToCategoryMap.set(entity, category.category);
|
||||
});
|
||||
});
|
||||
customEntities.forEach((entity) => {
|
||||
entityToCategoryMap.set(entity, "Custom");
|
||||
});
|
||||
const entityToCategoryMap = new Map<string, string>([
|
||||
...entityCategories.flatMap((category) =>
|
||||
category.entities.map((entity): [string, string] => [entity, category.category]),
|
||||
),
|
||||
...customEntities.map((entity): [string, string] => [entity, "Custom"]),
|
||||
]);
|
||||
|
||||
// Filter entities based on selected categories
|
||||
const filteredEntities = allEntities.filter((entity) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue