Skip to content

Commit dd9a42f

Browse files
refactor : pii_list and compliance_list
1 parent 01c2d5d commit dd9a42f

File tree

3 files changed

+54
-9
lines changed

3 files changed

+54
-9
lines changed

plugins/walledai/guardrails.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import { post, getText, getCurrentContentPart } from '../utils';
88

99
const API_URL = 'https://services.walled.ai/v1/guardrail/moderate';
1010

11+
const DEFAULT_PII_LIST = [
12+
"Person's Name",
13+
'Address',
14+
'Email Id',
15+
'Contact No',
16+
'Date Of Birth',
17+
'Unique Id',
18+
'Financial Data',
19+
];
20+
21+
const DEFAULT_GREETINGS_LIST = [
22+
'Casual & Friendly',
23+
'Professional & Polite',
24+
];
25+
1126
export const handler: PluginHandler = async (
1227
context: PluginContext,
1328
parameters: PluginParameters,
@@ -40,13 +55,15 @@ export const handler: PluginHandler = async (
4055
text: text,
4156
text_type: parameters.text_type || 'prompt',
4257
generic_safety_check: parameters.generic_safety_check ?? true,
43-
greetings_list: parameters.greetings_list || ['generalgreetings'],
58+
greetings_list: parameters.greetings_list || DEFAULT_GREETINGS_LIST,
59+
pii_list: parameters.pii_list || DEFAULT_PII_LIST,
60+
compliance_list: parameters.compliance_list || [],
4461
};
4562
// Prepare headers
4663
const requestOptions = {
4764
headers: {
4865
'Content-Type': 'application/json',
49-
Authorization: `Bearer ${parameters.credentials.apiKey}`, // Uncomment if API key is required
66+
Authorization: `Bearer ${parameters.credentials.apiKey}`,
5067
},
5168
};
5269

plugins/walledai/manifest.json

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@
6060
}
6161
],
6262
"items": {
63-
"type": "string",
64-
"default": ["generalgreetings"]
65-
}
63+
"type": "string"
64+
},
65+
"default": [
66+
"Casual & Friendly",
67+
"Professional & Polite"
68+
]
6669
},
6770
"pii_list": {
6871
"type": "array",
@@ -84,7 +87,16 @@
8487
"Unique Id",
8588
"Financial Data"
8689
]
87-
}
90+
},
91+
"default": [
92+
"Person's Name",
93+
"Address",
94+
"Email Id",
95+
"Contact No",
96+
"Date Of Birth",
97+
"Unique Id",
98+
"Financial Data"
99+
]
88100
},
89101
"compliance_list": {
90102
"type": "array",
@@ -97,7 +109,8 @@
97109
],
98110
"items": {
99111
"type": "string"
100-
}
112+
},
113+
"default": []
101114
}
102115
}
103116
}

plugins/walledai/walledai.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ describe('WalledAI Guardrail Plugin Handler (integration)', () => {
1111
credentials: testCreds,
1212
text_type: 'prompt',
1313
generic_safety_check: true,
14-
greetings_list: ['generalgreetings'],
14+
greetings_list: ['Casual & Friendly', 'Professional & Polite'],
1515
pii_list: ["Person's Name", 'Address'],
16-
compliance_list: [],
16+
compliance_list: ['questions on medicine'],
1717
};
1818

1919
const makeContext = (text: string): PluginContext => ({
@@ -80,4 +80,19 @@ describe('WalledAI Guardrail Plugin Handler (integration)', () => {
8080
expect(result.verdict).toBe(true);
8181
expect(result.error).toBeNull();
8282
});
83+
84+
it('handles compliance_list parameter', async () => {
85+
const context = makeContext('This is a test for compliance.');
86+
87+
const paramsWithCompliance: PluginParameters = {
88+
...baseParams,
89+
compliance_list: ['GDPR', 'PCI-DSS'],
90+
};
91+
92+
const result = await handler(context, paramsWithCompliance, 'beforeRequestHook');
93+
94+
expect(result.error).toBeNull();
95+
expect(result.data).toBeDefined();
96+
// Optionally, check if compliance_list was respected in the response if API supports it
97+
});
8398
});

0 commit comments

Comments
 (0)