-
Notifications
You must be signed in to change notification settings - Fork 715
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?
Conversation
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.
Clean refactoring to migrate from Walled AI guardrails to walledprotect API. Code changes look good with proper API endpoint and authentication updates.
Skipped files
plugins/walledai/manifest.json
: Skipped file pattern
const requestBody = { | ||
text: text, | ||
text_type: parameters.text_type || 'prompt', | ||
generic_safety_check: parameters.generic_safety_check ?? true, |
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: Removed text_type
parameter from request body without explanation
Fix: Consider documenting why this parameter was removed or if it's still needed for the new API
Impact: May affect API compatibility if the new endpoint expects this parameter
The removal of text_type
parameter should be verified against the new API documentation to ensure compatibility.
@@ -18,7 +18,7 @@ | |||
'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 comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Code Refactor
Issue: Default greetings list reduced from two options to one
Fix: Verify if 'Professional & Polite' option is no longer supported by the new API
Impact: May change default behavior for users who relied on both greeting styles
const DEFAULT_GREETINGS_LIST = ['Casual & Friendly']; | |
const DEFAULT_GREETINGS_LIST = ['Casual & Friendly']; |
let text = textArray | ||
.filter((text) => text) | ||
.join('\n') | ||
.trim(); |
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.
⚡️ Performance Improvement
Issue: Text processing can be optimized with method chaining
Fix: Good improvement to add trim() and format the chain for better readability
Impact: Removes unnecessary whitespace and improves code maintainability
let text = textArray | |
.filter((text) => text) | |
.join('\n') | |
.trim(); | |
let text = textArray | |
.filter((text) => text) | |
.join('\ | |
') | |
.trim(); |
it('should handle conversational text format', async () => { | ||
const context = { | ||
requestType: 'chatComplete', | ||
request: { | ||
json: { | ||
messages: [ | ||
{ role: 'user', content: 'Hi' }, | ||
{ role: 'assistant', content: 'Hello, how can I help you?' }, | ||
], | ||
}, | ||
}, | ||
response: {}, | ||
}; | ||
|
||
const parameters = { | ||
credentials: testCreds, | ||
text_type: 'prompt', | ||
generic_safety_check: true, | ||
greetings_list: ['Casual & Friendly', 'Professional & Polite'], | ||
pii_list: ["Person's Name", 'Address'], | ||
compliance_list: ['questions on medicine'], | ||
}; | ||
|
||
const eventType = 'beforeRequestHook'; | ||
|
||
const result = await handler(context as any, parameters, eventType); | ||
expect(result).toHaveProperty('verdict'); | ||
expect(result).toHaveProperty('data'); | ||
}); |
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.
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.
Simple configuration change to rename walledai guardrail to walledprotect. Code quality is good with proper formatting.
@@ -138,6 +138,6 @@ export const plugins = { | |||
intercept: panwPrismaAirsintercept, | |||
}, | |||
walledai: { | |||
guardrails: walledaiguardrails, | |||
walledprotect: walledaiguardrails, | |||
}, | |||
}; |
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: Missing newline at end of file
Fix: Add newline at end of file to follow standard conventions
Impact: Improves code consistency and follows common formatting standards
}; | |
}; |
Description
Modified the existing walledai guardrail , changed to walledprotect and changed authentication mode
Motivation
WalledAi guardrail was renamed and the existing base url was updated and authentication mode as well.
Type of Change
How Has This Been Tested?
Screenshots (if applicable)
Checklist
Related Issues
#1197