Skip to content

Commit 12cdd2b

Browse files
authored
Upgrading deps to the latest one (#241)
* * update slack to MLSecOps * * upgrade deps * * all ruff issues fixed * * fixing issues with upgrades of presidio
1 parent 2090432 commit 12cdd2b

File tree

9 files changed

+33
-41
lines changed

9 files changed

+33
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.PHONY: install-dev
44
install-dev: ## Install development dependencies.
55
@echo "Installing development dependencies..."
6-
@python -m pip install ".[dev, onnxruntime]"
6+
@python -m pip install ".[dev, onnxruntime]" -U
77
@pre-commit install
88

99
.PHONY: lint

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ stars](https://img.shields.io/github/stars/protectai/llm-guard.svg?style=social&
1212
[![Downloads](https://static.pepy.tech/badge/llm-guard)](https://pepy.tech/project/llm-guard)
1313
[![Downloads](https://static.pepy.tech/badge/llm-guard/month)](https://pepy.tech/project/llm-guard)
1414

15-
<a href="https://join.slack.com/t/laiyerai/shared_invite/zt-28jv3ci39-sVxXrLs3rQdaN3mIl9IT~w"><img src="https://github.com/protectai/llm-guard/blob/main/docs/assets/join-our-slack-community.png?raw=true" width="200" alt="Join Our Slack Community"></a>
15+
<a href="https://mlsecops.com/slack"><img src="https://github.com/protectai/llm-guard/blob/main/docs/assets/join-our-slack-community.png?raw=true" width="200" alt="Join Our Slack Community"></a>
1616

1717
## What is LLM Guard?
1818

@@ -108,7 +108,7 @@ we would love to have you as part of our community.
108108
Join our Slack to give us feedback, connect with the maintainers and fellow users, ask questions,
109109
get help for package usage or contributions, or engage in discussions about LLM security!
110110

111-
<a href="https://join.slack.com/t/laiyerai/shared_invite/zt-28jv3ci39-sVxXrLs3rQdaN3mIl9IT~w"><img src="https://github.com/protectai/llm-guard/blob/main/docs/assets/join-our-slack-community.png?raw=true" width="200" alt="Join Our Slack Community"></a>
111+
<a href="https://mlsecops.com/slack"><img src="https://github.com/protectai/llm-guard/blob/main/docs/assets/join-our-slack-community.png?raw=true" width="200" alt="Join Our Slack Community"></a>
112112

113113
### Production Support
114114

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LLM Guard by [Protect AI](https://protectai.com/llm-guard) is a comprehensive to
44

55
[**Playground**](https://huggingface.co/spaces/ProtectAI/llm-guard-playground) | [**Changelog**](./changelog.md)
66

7-
<a href="https://join.slack.com/t/laiyerai/shared_invite/zt-28jv3ci39-sVxXrLs3rQdaN3mIl9IT~w"><img src="./assets/join-our-slack-community.png" width="200" alt="Join Our Slack Community"></a>
7+
<a href="https://mlsecops.com/slack"><img src="./assets/join-our-slack-community.png" width="200" alt="Join Our Slack Community"></a>
88

99
## What is LLM Guard?
1010

@@ -55,4 +55,4 @@ we would love to have you as part of our community.
5555
Join our Slack to give us feedback, connect with the maintainers and fellow users, ask questions,
5656
get help for package usage or contributions, or engage in discussions about LLM security!
5757

58-
<a href="https://join.slack.com/t/laiyerai/shared_invite/zt-28jv3ci39-sVxXrLs3rQdaN3mIl9IT~w"><img src="./assets/join-our-slack-community.png" width="200" alt="Join Our Slack Community"></a>
58+
<a href="https://mlsecops.com/slack"><img src="./assets/join-our-slack-community.png" width="200" alt="Join Our Slack Community"></a>

llm_guard/input_scanners/anonymize_helpers/analyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _add_recognizers(
9393
return registry
9494

9595

96-
def _get_nlp_engine(languages: list[str] = ["en"]) -> NlpEngine:
96+
def _get_nlp_engine(languages: list[str]) -> NlpEngine:
9797
models = []
9898

9999
for language in languages:
@@ -143,7 +143,7 @@ def get_analyzer(
143143
) -> AnalyzerEngine:
144144
nlp_engine = _get_nlp_engine(languages=supported_languages)
145145

146-
registry = RecognizerRegistry()
146+
registry = RecognizerRegistry(supported_languages=supported_languages)
147147
registry.load_predefined_recognizers(nlp_engine=nlp_engine)
148148
registry = _add_recognizers(registry, regex_groups, custom_names, supported_languages)
149149
registry.add_recognizer(recognizer)

llm_guard/input_scanners/anonymize_helpers/transformers_recognizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from presidio_analyzer import AnalysisExplanation, EntityRecognizer, RecognizerResult
77
from presidio_analyzer.nlp_engine import NlpArtifacts
8-
from transformers import TokenClassificationPipeline
8+
from transformers.pipelines.token_classification import TokenClassificationPipeline
99

1010
from llm_guard.model import Model
1111
from llm_guard.transformers_helpers import get_tokenizer_and_model_for_ner
@@ -60,7 +60,7 @@ class TransformersRecognizer(EntityRecognizer):
6060
chunk_length: int
6161
id_entity_name: str
6262
id_score_reduction: float
63-
pipeline: transformers.Pipeline | None
63+
pipeline: transformers.pipelines.base.Pipeline | None
6464

6565
def load(self) -> None:
6666
pass
@@ -139,7 +139,7 @@ def _load_pipeline(
139139
self.model.pipeline_kwargs["ignore_labels"] = self.ignore_labels
140140

141141
transformers = cast("transformers", lazy_load_dep("transformers"))
142-
self.pipeline = transformers.pipeline(
142+
self.pipeline = transformers.pipelines.pipeline(
143143
"ner",
144144
model=tf_model,
145145
tokenizer=tf_tokenizer,

llm_guard/input_scanners/prompt_injection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from enum import Enum
44

5-
from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast
5+
from transformers.tokenization_utils import PreTrainedTokenizer
6+
from transformers.tokenization_utils_fast import PreTrainedTokenizerFast
67

78
from llm_guard.model import Model
89
from llm_guard.transformers_helpers import get_tokenizer_and_model_for_classification, pipeline

llm_guard/transformers_helpers.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
from functools import lru_cache
55
from typing import Literal, get_args
66

7-
from transformers import (
8-
PreTrainedModel,
9-
PreTrainedTokenizer,
10-
PreTrainedTokenizerFast,
11-
TFPreTrainedModel,
12-
)
13-
147
from .exception import LLMGuardValidationError
158
from .model import Model
169
from .util import device, get_logger, lazy_load_dep
@@ -155,8 +148,8 @@ def get_tokenizer_and_model_for_ner(
155148

156149
def pipeline(
157150
task: str,
158-
model: PreTrainedModel | TFPreTrainedModel,
159-
tokenizer: PreTrainedTokenizer | PreTrainedTokenizerFast,
151+
model,
152+
tokenizer,
160153
**kwargs,
161154
):
162155
if task not in get_args(ClassificationTask):

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extra:
8888
- icon: fontawesome/brands/linkedin
8989
link: https://www.linkedin.com/company/protect-ai
9090
- icon: fontawesome/brands/slack
91-
link: https://join.slack.com/t/laiyerai/shared_invite/zt-28jv3ci39-sVxXrLs3rQdaN3mIl9IT~w
91+
link: https://mlsecops.com/slack
9292
- icon: fontawesome/solid/globe
9393
link: https://protectai.com/llm-guard
9494
analytics:

pyproject.toml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,44 @@ classifiers = [
2020
requires-python = ">=3.10,<3.13"
2121

2222
dependencies = [
23-
"bc-detect-secrets==1.5.36",
24-
"faker>=36,<37",
23+
"bc-detect-secrets==1.5.43",
24+
"faker>=37,<38",
2525
"fuzzysearch>=0.7,<0.9",
26-
"json-repair>=0.39,<0.40",
26+
"json-repair==0.44.1",
2727
"nltk>=3.9.1,<4",
28-
"presidio-analyzer==2.2.354",
29-
"presidio-anonymizer==2.2.354",
28+
"presidio-analyzer==2.2.358",
29+
"presidio-anonymizer==2.2.358",
3030
"regex==2024.11.6",
3131
"tiktoken>=0.9,<1.0",
3232
"torch>=2.4.0",
33-
"transformers==4.48.3",
34-
"structlog>=24",
35-
"oldest-supported-numpy",
36-
"spacy-pkuseg==1.0.0"
33+
"transformers==4.51.3",
34+
"structlog>=24"
3735
]
3836

3937
[project.optional-dependencies]
4038
onnxruntime = [
41-
"optimum[onnxruntime]==1.24.0",
39+
"optimum[onnxruntime]==1.25.2",
4240
]
4341
onnxruntime-gpu = [
44-
"optimum[onnxruntime-gpu]==1.24.0",
42+
"optimum[onnxruntime-gpu]==1.25.2",
4543
]
4644
docs-dev = [
4745
"mkdocs>=1.6,<2",
48-
"mkdocs-autorefs==1.3.1",
49-
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
46+
"mkdocs-autorefs==1.4.1",
47+
"mkdocs-git-revision-date-localized-plugin>=1.4.0",
5048
"mkdocs-jupyter>=0.25.1",
51-
"mkdocs-material>=9.6.5",
49+
"mkdocs-material>=9.6.14",
5250
"mkdocs-material-extensions>=1.3.1",
53-
"mkdocs-swagger-ui-tag>=0.6.11",
51+
"mkdocs-swagger-ui-tag>=0.7.1",
5452
]
5553
dev = [
5654
"llm_guard[docs-dev]",
5755
"autoflake>=2,<3",
58-
"pytest>=8.0.0,<9",
59-
"pytest-cov>=5.0.0,<6",
60-
"pre-commit>=3.8,<5",
61-
"pyright~=1.1.394",
62-
"ruff==0.9.6",
56+
"pytest>=8.3.5,<9",
57+
"pytest-cov>=6.1.1,<7",
58+
"pre-commit>=4.2.0,<5",
59+
"pyright~=1.1.400",
60+
"ruff==0.11.10",
6361
]
6462

6563
[project.urls]

0 commit comments

Comments
 (0)