-
Notifications
You must be signed in to change notification settings - Fork 70
LCORE-1259: Safety Shield configuration for query & streaming query #1100
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?
LCORE-1259: Safety Shield configuration for query & streaming query #1100
Conversation
Signed-off-by: Lucas <lyoon@redhat.com>
Signed-off-by: Lucas <lyoon@redhat.com>
WalkthroughThis PR adds an optional Changes
Sequence DiagramsequenceDiagram
participant Client
participant Endpoint as Query Endpoint
participant ShieldUtil as Shield Utility
participant ShieldAPI as Shield API
Client->>Endpoint: POST query with shield_ids
Endpoint->>ShieldUtil: run_shield_moderation(client, input_text, shield_ids)
ShieldUtil->>ShieldAPI: list_shields()
ShieldAPI-->>ShieldUtil: all_shields
ShieldUtil->>ShieldUtil: filter shields by shield_ids
alt shield_ids specified but no valid shields
ShieldUtil-->>Endpoint: HTTPException 422
Endpoint-->>Client: Error response
else shield_ids empty list
ShieldUtil->>Endpoint: ShieldModerationResult (not_blocked)
Endpoint-->>Client: Success response
else shield_ids with valid shields
ShieldUtil->>ShieldAPI: create_moderation(model, input_text)
ShieldAPI-->>ShieldUtil: moderation_result
ShieldUtil->>Endpoint: ShieldModerationResult
Endpoint-->>Client: Success response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
tisnik
left a comment
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.
Thank you for your PR. It seems ok, but we'd also need to introduce new configuration parameter that will enable or disable this behavior. Because let's say this is ok for your purposes, but other systems want not to allow any overrides like this. Please look at existing configuration option disable_query_system_prompt. Would you be so kind to add something similar to our PR? Thank you in advance.
Description
As a developer using Lightspeed Core Stack, I want to specify which safety shields to apply per query, so that I can use different shield configurations for different use cases without restarting the service.
Updated query v1, query v2, and streaming query to take in an extra parameter to identify which shields to apply. If the request parameter is not provided, it will apply all safety shields (same as before).
Type of change
Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
Summary by CodeRabbit
Release Notes
New Features
Tests