Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sentinelguard"
version = "0.0.3"
version = "0.0.4"
description = "A comprehensive, production-ready LLM security and guardrails framework"
readme = "README.md"
license = {text = "MIT"}
Expand Down Expand Up @@ -36,7 +36,7 @@ dependencies = [
"presidio-analyzer>=2.2.0",
"presidio-anonymizer>=2.2.0",
"spacy>=3.6.0",
"en-core-web-lg>=3.6.0",
"en-core-web-lg>=3.7.1",
# Model-based detection (HuggingFace)
"transformers>=4.30.0",
"torch>=2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sentinelguard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
guard = SentinelGuard(config=config)
"""

__version__ = "0.0.3"
__version__ = "0.0.4"
__author__ = "SentinelGuard Contributors"

from sentinelguard.core.guard import SentinelGuard
Expand Down
5 changes: 2 additions & 3 deletions sentinelguard/scanners/output/bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import re
from typing import Any, ClassVar, Dict, List, Optional, Tuple

from transformers import pipeline

from sentinelguard.core.scanner import OutputScanner, RiskLevel, ScanResult, register_scanner

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -112,8 +110,9 @@ def __init__(
def _load_model(self) -> None:
if self._model is None:
try:
from transformers import pipeline as hf_pipeline
logger.info("Loading bias detection model: %s", _BIAS_MODEL_ID)
self._model = pipeline("text-classification", model=_BIAS_MODEL_ID)
self._model = hf_pipeline("text-classification", model=_BIAS_MODEL_ID)
except Exception as exc:
logger.warning("Failed to load bias model, falling back to regex only: %s", exc)
self._model = False # sentinel: tried and failed
Expand Down
5 changes: 2 additions & 3 deletions sentinelguard/scanners/prompt/jailbreak.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import re
from typing import Any, ClassVar, Dict, List, Optional, Tuple

from transformers import pipeline

from sentinelguard.core.scanner import PromptScanner, RiskLevel, ScanResult, register_scanner

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -179,8 +177,9 @@ def __init__(
def _load_model(self) -> None:
if self._model is None:
try:
from transformers import pipeline as hf_pipeline
logger.info("Loading jailbreak detection model: %s", _JAILBREAK_MODEL_ID)
self._model = pipeline("text-classification", model=_JAILBREAK_MODEL_ID)
self._model = hf_pipeline("text-classification", model=_JAILBREAK_MODEL_ID)
except Exception as exc:
logger.warning("Failed to load jailbreak model, falling back to patterns only: %s", exc)
self._model = False
Expand Down
5 changes: 2 additions & 3 deletions sentinelguard/scanners/prompt/prompt_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import re
from typing import Any, ClassVar, List, Optional

from transformers import pipeline

from sentinelguard.core.scanner import PromptScanner, RiskLevel, ScanResult, register_scanner

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -99,8 +97,9 @@ def __init__(
def _load_model(self) -> None:
if self._model is None:
try:
from transformers import pipeline as hf_pipeline
logger.info("Loading prompt injection model: %s", _INJECTION_MODEL_ID)
self._model = pipeline("text-classification", model=_INJECTION_MODEL_ID)
self._model = hf_pipeline("text-classification", model=_INJECTION_MODEL_ID)
except Exception as exc:
logger.warning("Failed to load injection model, falling back to patterns+heuristics: %s", exc)
self._model = False
Expand Down
5 changes: 2 additions & 3 deletions sentinelguard/scanners/prompt/toxicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import re
from typing import Any, ClassVar, Dict, List, Optional

from transformers import pipeline

from sentinelguard.core.scanner import PromptScanner, RiskLevel, ScanResult, register_scanner

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,8 +84,9 @@ def __init__(
def _load_model(self) -> None:
if self._model is None:
try:
from transformers import pipeline as hf_pipeline
logger.info("Loading toxicity model: %s", _TOXICITY_MODEL_ID)
self._model = pipeline("text-classification", model=_TOXICITY_MODEL_ID, top_k=None)
self._model = hf_pipeline("text-classification", model=_TOXICITY_MODEL_ID, top_k=None)
except Exception as exc:
logger.warning("Failed to load toxicity model, falling back to patterns: %s", exc)
self._model = False
Expand Down
Loading