Open
Description
Did you check docs and existing issues?
- I have read all the NeMo-Guardrails docs
- I have updated the package to the latest version before submitting this issue
- (optional) I have used the develop branch
- I have searched the existing issues of NeMo-Guardrails
Python version (python --version)
Python 3.12.0
Operating system/version
MacOS 15.5
NeMo-Guardrails version (if you must use a specific version and not the latest
0.14.0
Describe the bug
The jailbreak detection module imports heavy dependencies (torch, transformers, sklearn) at module level, even when using the NIM-based approach. This means users need to install these dependencies even if they're not using the local model-based jailbreak detection.
Steps To Reproduce
- Install NeMo-Guardrails without torch, transformers, or sklearn
- Configure jailbreak detection to use NIM-based approach:
rails:
config:
jailbreak_detection:
nim_url: "your-nim-url"
nim_port: 8000
- Try to use the jailbreak detection feature
- Observe that the code fails to import required dependencies
Expected Behavior
When using the NIM-based approach for jailbreak detection, the code should not require torch, transformers, or sklearn to be installed. These dependencies should only be required when using the local model-based approach.
Actual Behavior
The code fails with import errors for torch, transformers, or sklearn even when using the NIM-based approach, because these dependencies are imported at module level rather than being lazy-loaded when needed.