feat: add tests for guardrails with huggingface detectors#369
feat: add tests for guardrails with huggingface detectors#369dbasunag merged 4 commits intoopendatahub-io:mainfrom
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes extend and modularize test fixtures and test classes for the Guardrails Orchestrator to support both built-in and Hugging Face detectors. New fixtures, routes, and runtime support are introduced for Hugging Face-based detectors, and the test suite is expanded to cover prompt injection detection scenarios with improved payload handling. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
The following are automatically added/executed:
Available user actions:
Supported labels{'/hold', '/wip', '/cherry-pick', '/lgtm', '/verified', '/build-push-pr-image'} |
94b28e4 to
7c5a058
Compare
|
/verified |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
tests/model_explainability/guardrails/conftest.py(8 hunks)tests/model_explainability/guardrails/test_guardrails.py(7 hunks)tests/model_explainability/guardrails/utils.py(1 hunks)tests/model_explainability/lm_eval/conftest.py(1 hunks)utilities/constants.py(1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
tests/model_explainability/guardrails/test_guardrails.py
[refactor] 156-156: Too many arguments (7/5)
(R0913)
[refactor] 156-156: Too many positional arguments (7/5)
(R0917)
[refactor] 201-201: Too many arguments (8/5)
(R0913)
[refactor] 201-201: Too many positional arguments (8/5)
(R0917)
[refactor] 229-229: Too many arguments (8/5)
(R0913)
[refactor] 229-229: Too many positional arguments (8/5)
(R0917)
🔇 Additional comments (4)
utilities/constants.py (1)
274-274: LGTM!The MinIO image update to support HuggingFace LLM models aligns with the PR's objective.
tests/model_explainability/guardrails/utils.py (1)
15-41: Well-structured enhancement to support detector configurations!The new
get_chat_detections_payloadfunction properly extends the payload construction with model and detector support, maintaining clear typing and documentation.tests/model_explainability/lm_eval/conftest.py (1)
38-38: Good choice using the instruction-tuned model variant!The Qwen2.5-0.5B-Instruct model is more appropriate for this fixture since it includes system instructions and chat templates.
tests/model_explainability/guardrails/test_guardrails.py (1)
1-249: Excellent test coverage for both detector backends!The test suite properly validates both built-in regex and HuggingFace prompt injection detectors with appropriate positive and negative test cases. The static analysis warnings about too many arguments can be safely ignored as they're standard for pytest fixtures.
|
Status of building tag latest: success. |
This PR adds a new test class with tests for the GuardrailsOrchestrator paired with HuggingFace detectors.
Description
These tests verify that the GuardrailsOrchestrator works as expected when using HuggingFace detectors
Steps:
- Deploy an LLM (Qwen2.5-0.5B-Instruct) using the vLLM SR.
- Deploy the GuardrailsOrchestrator.
- Deploy a prompt injection detector using the HuggingFace SR.
- Check that the detector works when we have an unsuitable input.
- Check that the detector works when we have a harmless input (no detection).
Also includes some utils functions and minor improvements.
How Has This Been Tested?
Running on PSI.
Merge criteria: