-
Notifications
You must be signed in to change notification settings - Fork 761
Fix : Walled Ai Guardrail changed to walledprotect #1316
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
2c85290
a7783c7
3dcf3d2
03be393
f8a0f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,7 +6,7 @@ import { | |||||||||||||||||||
} from '../types'; | ||||||||||||||||||||
import { post, getText, getCurrentContentPart } from '../utils'; | ||||||||||||||||||||
|
||||||||||||||||||||
const API_URL = 'https://services.walled.ai/v1/guardrail/moderate'; | ||||||||||||||||||||
const API_URL = 'https://services.walled.ai/v1/walled-protect'; | ||||||||||||||||||||
|
||||||||||||||||||||
const DEFAULT_PII_LIST = [ | ||||||||||||||||||||
"Person's Name", | ||||||||||||||||||||
|
@@ -18,7 +18,7 @@ const DEFAULT_PII_LIST = [ | |||||||||||||||||||
'Financial Data', | ||||||||||||||||||||
]; | ||||||||||||||||||||
|
||||||||||||||||||||
const DEFAULT_GREETINGS_LIST = ['Casual & Friendly', 'Professional & Polite']; | ||||||||||||||||||||
const DEFAULT_GREETINGS_LIST = ['Casual & Friendly']; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Code Refactor Issue: Default greetings list reduced from two options to one
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
export const handler: PluginHandler = async ( | ||||||||||||||||||||
context: PluginContext, | ||||||||||||||||||||
|
@@ -45,12 +45,14 @@ export const handler: PluginHandler = async ( | |||||||||||||||||||
data: null, | ||||||||||||||||||||
}; | ||||||||||||||||||||
} | ||||||||||||||||||||
let text = textArray.filter((text) => text).join('\n'); | ||||||||||||||||||||
let text = textArray | ||||||||||||||||||||
.filter((text) => text) | ||||||||||||||||||||
.join('\n') | ||||||||||||||||||||
.trim(); | ||||||||||||||||||||
Comment on lines
+48
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡️ Performance Improvement Issue: Text processing can be optimized with method chaining
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
// Prepare request body | ||||||||||||||||||||
const requestBody = { | ||||||||||||||||||||
text: text, | ||||||||||||||||||||
text_type: parameters.text_type || 'prompt', | ||||||||||||||||||||
generic_safety_check: parameters.generic_safety_check ?? true, | ||||||||||||||||||||
Comment on lines
54
to
56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Code Refactor Issue: Removed The removal of |
||||||||||||||||||||
greetings_list: parameters.greetings_list || DEFAULT_GREETINGS_LIST, | ||||||||||||||||||||
pii_list: parameters.pii_list || DEFAULT_PII_LIST, | ||||||||||||||||||||
|
@@ -60,7 +62,7 @@ export const handler: PluginHandler = async ( | |||||||||||||||||||
const requestOptions = { | ||||||||||||||||||||
headers: { | ||||||||||||||||||||
'Content-Type': 'application/json', | ||||||||||||||||||||
Authorization: `Bearer ${parameters.credentials.apiKey}`, | ||||||||||||||||||||
'x-api-key': parameters.credentials.apiKey, | ||||||||||||||||||||
}, | ||||||||||||||||||||
}; | ||||||||||||||||||||
|
||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Code Refactor
Issue: New test case has hardcoded test data that could be extracted to constants
Fix: Consider extracting test messages and parameters to improve maintainability
Impact: Makes tests more readable and easier to maintain
The test looks comprehensive but could benefit from extracting the mock data to constants for better organization.