llm-guardrails-maintained 0.3.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llm_guardrails_maintained-0.3.17/LICENSE +21 -0
- llm_guardrails_maintained-0.3.17/PKG-INFO +228 -0
- llm_guardrails_maintained-0.3.17/README.md +150 -0
- llm_guardrails_maintained-0.3.17/llm_guard/__init__.py +4 -0
- llm_guardrails_maintained-0.3.17/llm_guard/evaluate.py +127 -0
- llm_guardrails_maintained-0.3.17/llm_guard/exception.py +4 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/__init__.py +42 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize.py +397 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/__init__.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/analyzer.py +162 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/faker.py +73 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/ner_mapping.py +364 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/__init__.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/phone_recognizer.py +7 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/zh/__init__.py +15 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/zh/crypto_recognizer.py +10 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/zh/custom_pattern_recognizer.py +18 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/zh/email_recognizer.py +14 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/predefined_recognizers/zh/ip_recognizer.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/regex_patterns.py +228 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/anonymize_helpers/transformers_recognizer.py +317 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/atr.py +235 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/ban_code.py +109 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/ban_competitors.py +180 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/ban_substrings.py +145 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/ban_topics.py +161 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/base.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/code.py +179 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/emotion_detection.py +289 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/gibberish.py +115 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/invisible_text.py +47 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/language.py +115 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/prompt_injection.py +199 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/regex.py +108 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets.py +502 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/__init__.py +0 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/adafruit.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/adobe.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/age_secret_key.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/airtable_api_key.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/algolia_api_key.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/alibaba.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/asana.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/atlassian_api_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/authress_access_key.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/beamer_api_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/bitbucket.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/bittrex.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/clojars_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/codecov_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/coinbase_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/confluent.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/contentful_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/databricks_api_token.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/datadog_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/defined_networking_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/digitalocean.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/discord.py +32 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/doppler_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/droneci_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/dropbox.py +32 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/duffel_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/dynatrace_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/easypost.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/etsy_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/facebook_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/fastly_api_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/finicity.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/finnhub_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/flickr_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/flutterwave.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/frameio_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/freshbooks_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/gcp_api_key.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/github_token.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/gitlab.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/gitter_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/gocardless_api_token.py +25 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/grafana.py +30 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/hashicorp_tf_api_token.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/heroku_api_key.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/hubspot_api_key.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/huggingface.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/intercom_api_key.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/jfrog.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/jwt.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/kraken_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/kucoin.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/launchdarkly_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/linear.py +26 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/linkedin.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/lob.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/mailgun.py +32 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/mapbox_api_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/mattermost_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/messagebird.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/microsoft_teams_webhook.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/netlify_access_token.py +24 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/new_relic.py +32 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/nytimes_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/okta_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/openai_api_key.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/planetscale.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/postman_api_token.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/prefect_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/pulumi_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/pypi_upload_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/rapidapi_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/readme_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/rubygems_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/scalingo_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sendbird.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sendgrid_api_token.py +19 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sendinblue_api_token.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sentry_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/shippo_api_token.py +21 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/shopify.py +31 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sidekiq.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/slack.py +38 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/snyk_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/squarespace_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/sumologic.py +22 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/telegram_bot_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/travisci_access_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/twitch_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/twitter.py +36 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/typeform_api_token.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/vault.py +20 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/yandex.py +28 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/secrets_plugins/zendesk_secret_key.py +23 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/sentiment.py +62 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/token_limit.py +80 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/toxicity.py +132 -0
- llm_guardrails_maintained-0.3.17/llm_guard/input_scanners/util.py +80 -0
- llm_guardrails_maintained-0.3.17/llm_guard/mixins.py +29 -0
- llm_guardrails_maintained-0.3.17/llm_guard/model.py +60 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/__init__.py +55 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/atr.py +73 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/ban_code.py +37 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/ban_competitors.py +47 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/ban_substrings.py +69 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/ban_topics.py +45 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/base.py +27 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/bias.py +107 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/code.py +49 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/deanonymize.py +155 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/emotion_detection.py +55 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/factual_consistency.py +93 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/gibberish.py +40 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/json.py +125 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/language.py +44 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/language_same.py +88 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/malicious_urls.py +117 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/no_refusal.py +154 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/reading_time.py +46 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/regex.py +42 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/relevance.py +168 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/sensitive.py +117 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/sentiment.py +29 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/toxicity.py +42 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/url_reachabitlity.py +60 -0
- llm_guardrails_maintained-0.3.17/llm_guard/output_scanners/util.py +109 -0
- llm_guardrails_maintained-0.3.17/llm_guard/transformers_helpers.py +173 -0
- llm_guardrails_maintained-0.3.17/llm_guard/util.py +241 -0
- llm_guardrails_maintained-0.3.17/llm_guard/vault.py +37 -0
- llm_guardrails_maintained-0.3.17/llm_guardrails_maintained.egg-info/PKG-INFO +228 -0
- llm_guardrails_maintained-0.3.17/llm_guardrails_maintained.egg-info/SOURCES.txt +174 -0
- llm_guardrails_maintained-0.3.17/llm_guardrails_maintained.egg-info/dependency_links.txt +1 -0
- llm_guardrails_maintained-0.3.17/llm_guardrails_maintained.egg-info/requires.txt +36 -0
- llm_guardrails_maintained-0.3.17/llm_guardrails_maintained.egg-info/top_level.txt +1 -0
- llm_guardrails_maintained-0.3.17/pyproject.toml +90 -0
- llm_guardrails_maintained-0.3.17/setup.cfg +4 -0
- llm_guardrails_maintained-0.3.17/tests/test_evaluate.py +112 -0
- llm_guardrails_maintained-0.3.17/tests/test_mixins.py +115 -0
- llm_guardrails_maintained-0.3.17/tests/test_model.py +104 -0
- llm_guardrails_maintained-0.3.17/tests/test_util.py +135 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Protect AI. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-guardrails-maintained
|
|
3
|
+
Version: 0.3.17
|
|
4
|
+
Summary: LLM Guard Rails - An actively maintained security toolkit for Large Language Model interactions. Features advanced sanitization, harmful language detection, data leakage prevention, and prompt injection resistance with continuous improvements and enhancements.
|
|
5
|
+
Author-email: Nikhil Singh Bora <nikhilsinghbora17@gmail.com>, "Protect AI (Original)" <community@protectai.com>
|
|
6
|
+
License: The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) Protect AI. All rights reserved.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: homepage, https://github.com/Nikhilsinghbora/llm-guardrails
|
|
29
|
+
Project-URL: documentation, https://github.com/Nikhilsinghbora/llm-guardrails/blob/main/README.md
|
|
30
|
+
Project-URL: repository, https://github.com/Nikhilsinghbora/llm-guardrails
|
|
31
|
+
Project-URL: issues, https://github.com/Nikhilsinghbora/llm-guardrails/issues
|
|
32
|
+
Project-URL: changelog, https://github.com/Nikhilsinghbora/llm-guardrails/blob/main/docs/changelog.md
|
|
33
|
+
Project-URL: source, https://github.com/Nikhilsinghbora/llm-guardrails
|
|
34
|
+
Project-URL: original-project, https://github.com/protectai/llm-guard
|
|
35
|
+
Keywords: llm,language model,security,adversarial attacks,prompt injection,prompt leakage,PII detection,self-hardening,firewall,atr-scanner,agent-threat-rules
|
|
36
|
+
Classifier: Development Status :: 4 - Beta
|
|
37
|
+
Classifier: Intended Audience :: Developers
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
44
|
+
Requires-Python: <3.15,>=3.10
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
Requires-Dist: bc-detect-secrets>=1.5.43
|
|
47
|
+
Requires-Dist: faker<38,>=37
|
|
48
|
+
Requires-Dist: fuzzysearch<0.9,>=0.7
|
|
49
|
+
Requires-Dist: json-repair>=0.44.1
|
|
50
|
+
Requires-Dist: nltk<4,>=3.9.1
|
|
51
|
+
Requires-Dist: presidio-analyzer>=2.2.362
|
|
52
|
+
Requires-Dist: presidio-anonymizer>=2.2.362
|
|
53
|
+
Requires-Dist: regex>=2024.11.6
|
|
54
|
+
Requires-Dist: tiktoken<1.0,>=0.9
|
|
55
|
+
Requires-Dist: torch>=2.4.0
|
|
56
|
+
Requires-Dist: transformers<5,>=4.52.1
|
|
57
|
+
Requires-Dist: structlog>=24
|
|
58
|
+
Provides-Extra: onnxruntime
|
|
59
|
+
Requires-Dist: optimum[onnxruntime]<2,>=1.26.0; extra == "onnxruntime"
|
|
60
|
+
Provides-Extra: onnxruntime-gpu
|
|
61
|
+
Requires-Dist: optimum[onnxruntime-gpu]<2,>=1.26.0; extra == "onnxruntime-gpu"
|
|
62
|
+
Provides-Extra: docs-dev
|
|
63
|
+
Requires-Dist: mkdocs<2,>=1.6; extra == "docs-dev"
|
|
64
|
+
Requires-Dist: mkdocs-autorefs==1.4.1; extra == "docs-dev"
|
|
65
|
+
Requires-Dist: mkdocs-git-revision-date-localized-plugin>=1.4.0; extra == "docs-dev"
|
|
66
|
+
Requires-Dist: mkdocs-jupyter>=0.25.1; extra == "docs-dev"
|
|
67
|
+
Requires-Dist: mkdocs-material>=9.6.14; extra == "docs-dev"
|
|
68
|
+
Requires-Dist: mkdocs-material-extensions>=1.3.1; extra == "docs-dev"
|
|
69
|
+
Requires-Dist: mkdocs-swagger-ui-tag>=0.7.1; extra == "docs-dev"
|
|
70
|
+
Provides-Extra: dev
|
|
71
|
+
Requires-Dist: llm_guard[docs-dev]; extra == "dev"
|
|
72
|
+
Requires-Dist: autoflake<3,>=2; extra == "dev"
|
|
73
|
+
Requires-Dist: pytest<9,>=8.3.5; extra == "dev"
|
|
74
|
+
Requires-Dist: pytest-cov<7,>=6.1.1; extra == "dev"
|
|
75
|
+
Requires-Dist: pre-commit<5,>=4.2.0; extra == "dev"
|
|
76
|
+
Requires-Dist: pyright~=1.1.400; extra == "dev"
|
|
77
|
+
Requires-Dist: ruff==0.11.10; extra == "dev"
|
|
78
|
+
|
|
79
|
+
# LLM Guard Rails - Comprehensive Security Toolkit for LLM Interactions
|
|
80
|
+
|
|
81
|
+
> **About**: This is an actively maintained fork of the original [LLM Guard](https://github.com/protectai/llm-guard) project by [Protect AI](https://protectai.com/llm-guard). We maintain enhancements and improvements beyond the original project, ensuring continuous updates and feature development.
|
|
82
|
+
|
|
83
|
+
LLM Guard Rails is a comprehensive security toolkit designed to fortify the safety and security of Large Language Model (LLM) interactions. It provides robust protection against various attack vectors and malicious inputs with actively maintained enhancements.
|
|
84
|
+
|
|
85
|
+
[**Documentation**](https://github.com/Nikhilsinghbora/llm-guardrails) | [**Original Project**](https://github.com/protectai/llm-guard) | [**Getting Started**](./docs/get_started/quickstart.md)
|
|
86
|
+
|
|
87
|
+
[](https://GitHub.com/protectai/llm-guard/stargazers/)
|
|
89
|
+
[](http://opensource.org/licenses/MIT)
|
|
90
|
+
[](https://github.com/psf/black)
|
|
91
|
+
[](https://pypi.org/project/llm-guard)
|
|
92
|
+
[](https://pepy.tech/project/llm-guard)
|
|
93
|
+
[](https://pepy.tech/project/llm-guard)
|
|
94
|
+
|
|
95
|
+
<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>
|
|
96
|
+
|
|
97
|
+
## What is LLM Guard?
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
By offering sanitization, detection of harmful language, prevention of data leakage, and resistance against prompt
|
|
102
|
+
injection attacks, LLM-Guard ensures that your interactions with LLMs remain safe and secure.
|
|
103
|
+
|
|
104
|
+
## Installation
|
|
105
|
+
|
|
106
|
+
Begin your journey with LLM Guard Rails by downloading the package:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
# Coming soon to PyPI as llm-guardrails
|
|
110
|
+
pip install llm-guard
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Or install from source:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
git clone https://github.com/Nikhilsinghbora/llm-guardrails.git
|
|
117
|
+
cd llm-guardrails
|
|
118
|
+
pip install -e .
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Getting Started
|
|
122
|
+
|
|
123
|
+
**Important Notes**:
|
|
124
|
+
|
|
125
|
+
- LLM Guard Rails is designed for easy integration and deployment in production environments. While it's ready to use
|
|
126
|
+
out-of-the-box, please be informed that we're constantly improving and updating the repository.
|
|
127
|
+
- Base functionality requires a limited number of libraries. As you explore more advanced features, necessary libraries
|
|
128
|
+
will be automatically installed.
|
|
129
|
+
- Ensure you're using Python version 3.10 or higher. Confirm with: `python --version`.
|
|
130
|
+
- We fully support Python 3.10, 3.11, 3.12, 3.13, and 3.14.
|
|
131
|
+
- Library installation issues? Consider upgrading pip: `python -m pip install --upgrade pip`.
|
|
132
|
+
|
|
133
|
+
**Examples**:
|
|
134
|
+
|
|
135
|
+
- Get started with [ChatGPT and LLM Guard](./examples/openai_api.py).
|
|
136
|
+
- Deploy LLM Guard as [API](https://protectai.github.io/llm-guard/api/overview/)
|
|
137
|
+
|
|
138
|
+
## Supported scanners
|
|
139
|
+
|
|
140
|
+
### Prompt scanners
|
|
141
|
+
|
|
142
|
+
- [Anonymize](https://protectai.github.io/llm-guard/input_scanners/anonymize/)
|
|
143
|
+
- [ATRScanner](./docs/input_scanners/atr.md) ⭐ **NEW**
|
|
144
|
+
- [BanCode](./docs/input_scanners/ban_code.md)
|
|
145
|
+
- [BanCompetitors](https://protectai.github.io/llm-guard/input_scanners/ban_competitors/)
|
|
146
|
+
- [BanSubstrings](https://protectai.github.io/llm-guard/input_scanners/ban_substrings/)
|
|
147
|
+
- [BanTopics](https://protectai.github.io/llm-guard/input_scanners/ban_topics/)
|
|
148
|
+
- [Code](https://protectai.github.io/llm-guard/input_scanners/code/)
|
|
149
|
+
- [Gibberish](https://protectai.github.io/llm-guard/input_scanners/gibberish/)
|
|
150
|
+
- [InvisibleText](https://protectai.github.io/llm-guard/input_scanners/invisible_text/)
|
|
151
|
+
- [Language](https://protectai.github.io/llm-guard/input_scanners/language/)
|
|
152
|
+
- [PromptInjection](https://protectai.github.io/llm-guard/input_scanners/prompt_injection/)
|
|
153
|
+
- [Regex](https://protectai.github.io/llm-guard/input_scanners/regex/)
|
|
154
|
+
- [Secrets](https://protectai.github.io/llm-guard/input_scanners/secrets/)
|
|
155
|
+
- [Sentiment](https://protectai.github.io/llm-guard/input_scanners/sentiment/)
|
|
156
|
+
- [TokenLimit](https://protectai.github.io/llm-guard/input_scanners/token_limit/)
|
|
157
|
+
- [Toxicity](https://protectai.github.io/llm-guard/input_scanners/toxicity/)
|
|
158
|
+
|
|
159
|
+
### Output scanners
|
|
160
|
+
|
|
161
|
+
- [ATRScanner](./docs/output_scanners/atr.md) ⭐ **NEW**
|
|
162
|
+
- [BanCode](./docs/output_scanners/ban_code.md)
|
|
163
|
+
- [BanCompetitors](https://protectai.github.io/llm-guard/output_scanners/ban_competitors/)
|
|
164
|
+
- [BanSubstrings](https://protectai.github.io/llm-guard/output_scanners/ban_substrings/)
|
|
165
|
+
- [BanTopics](https://protectai.github.io/llm-guard/output_scanners/ban_topics/)
|
|
166
|
+
- [Bias](https://protectai.github.io/llm-guard/output_scanners/bias/)
|
|
167
|
+
- [Code](https://protectai.github.io/llm-guard/output_scanners/code/)
|
|
168
|
+
- [Deanonymize](https://protectai.github.io/llm-guard/output_scanners/deanonymize/)
|
|
169
|
+
- [JSON](https://protectai.github.io/llm-guard/output_scanners/json/)
|
|
170
|
+
- [Language](https://protectai.github.io/llm-guard/output_scanners/language/)
|
|
171
|
+
- [LanguageSame](https://protectai.github.io/llm-guard/output_scanners/language_same/)
|
|
172
|
+
- [MaliciousURLs](https://protectai.github.io/llm-guard/output_scanners/malicious_urls/)
|
|
173
|
+
- [NoRefusal](https://protectai.github.io/llm-guard/output_scanners/no_refusal/)
|
|
174
|
+
- [ReadingTime](https://protectai.github.io/llm-guard/output_scanners/reading_time/)
|
|
175
|
+
- [FactualConsistency](https://protectai.github.io/llm-guard/output_scanners/factual_consistency/)
|
|
176
|
+
- [Gibberish](https://protectai.github.io/llm-guard/output_scanners/gibberish/)
|
|
177
|
+
- [Regex](https://protectai.github.io/llm-guard/output_scanners/regex/)
|
|
178
|
+
- [Relevance](https://protectai.github.io/llm-guard/output_scanners/relevance/)
|
|
179
|
+
- [Sensitive](https://protectai.github.io/llm-guard/output_scanners/sensitive/)
|
|
180
|
+
- [Sentiment](https://protectai.github.io/llm-guard/output_scanners/sentiment/)
|
|
181
|
+
- [Toxicity](https://protectai.github.io/llm-guard/output_scanners/toxicity/)
|
|
182
|
+
- [URLReachability](https://protectai.github.io/llm-guard/output_scanners/url_reachability/)
|
|
183
|
+
|
|
184
|
+
## Community, Contributing, Docs & Support
|
|
185
|
+
|
|
186
|
+
LLM Guard Rails is an open source solution maintained as an active fork of the original LLM Guard project.
|
|
187
|
+
We are committed to a transparent development process and highly appreciate any contributions.
|
|
188
|
+
Whether you are helping us fix bugs, propose new features, improve our documentation or spread the word,
|
|
189
|
+
we would love to have you as part of our community.
|
|
190
|
+
|
|
191
|
+
### How We Differ
|
|
192
|
+
|
|
193
|
+
- **Active Development**: We maintain and release updates more frequently than the original project
|
|
194
|
+
- **Feature Requests Welcome**: We actively review and implement community feature requests
|
|
195
|
+
- **Responsive Maintenance**: Issues and PRs receive timely reviews and updates
|
|
196
|
+
|
|
197
|
+
### Recent Improvements & Updates
|
|
198
|
+
|
|
199
|
+
**Security & Bug Fixes:**
|
|
200
|
+
- ✅ Fixed CVE-2026-26007: Updated `presidio-anonymizer` to ≥2.2.362
|
|
201
|
+
- ✅ Fixed critical transformers vulnerability (GHSA-phhr-52qp-3mj4)
|
|
202
|
+
- ✅ Fixed Anonymize scanner to properly respect language parameter (#337)
|
|
203
|
+
- ✅ Fixed PromptInjection tokenizer initialization bug (#331)
|
|
204
|
+
- ✅ Fixed MaliciousURLs missing top_k parameter TypeError (#318)
|
|
205
|
+
|
|
206
|
+
**New Features & Enhancements:**
|
|
207
|
+
- ✅ **Python 3.13+ Support**: Full compatibility with Python 3.13 and 3.14
|
|
208
|
+
- ✅ **ATRScanner**: New Agent Threat Rule scanner with 10+ built-in detection patterns
|
|
209
|
+
- ✅ **ThresholdMixin**: Dynamically adjust scanner sensitivity without model reloading
|
|
210
|
+
- ✅ **Model.from_local()**: Factory method for locally-downloaded HuggingFace models
|
|
211
|
+
- ✅ Improved dependency management for better compatibility
|
|
212
|
+
|
|
213
|
+
### Get Involved
|
|
214
|
+
|
|
215
|
+
- Give us a ⭐️ github star ⭐️ on the top of this page to support what we're doing,
|
|
216
|
+
it means a lot for open source projects!
|
|
217
|
+
- Read our
|
|
218
|
+
[docs](./docs/index.md)
|
|
219
|
+
for more info about how to use and customize LLM Guard Rails, and for step-by-step tutorials.
|
|
220
|
+
- Post a [Github Issue](https://github.com/Nikhilsinghbora/llm-guardrails/issues) to submit a bug report, feature request, or suggest an improvement.
|
|
221
|
+
- To contribute to the package, check out our [contribution guidelines](CONTRIBUTING.md), and open a PR.
|
|
222
|
+
|
|
223
|
+
### Support & Contact
|
|
224
|
+
|
|
225
|
+
We're eager to provide personalized assistance and discuss feature requests or improvements.
|
|
226
|
+
|
|
227
|
+
- [Send Email ✉️](mailto:nikhilsinghbora17@gmail.com) - Open to feature requests, improvements, and collaboration
|
|
228
|
+
- [GitHub Issues](https://github.com/Nikhilsinghbora/llm-guardrails/issues) - Report bugs or request features
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# LLM Guard Rails - Comprehensive Security Toolkit for LLM Interactions
|
|
2
|
+
|
|
3
|
+
> **About**: This is an actively maintained fork of the original [LLM Guard](https://github.com/protectai/llm-guard) project by [Protect AI](https://protectai.com/llm-guard). We maintain enhancements and improvements beyond the original project, ensuring continuous updates and feature development.
|
|
4
|
+
|
|
5
|
+
LLM Guard Rails is a comprehensive security toolkit designed to fortify the safety and security of Large Language Model (LLM) interactions. It provides robust protection against various attack vectors and malicious inputs with actively maintained enhancements.
|
|
6
|
+
|
|
7
|
+
[**Documentation**](https://github.com/Nikhilsinghbora/llm-guardrails) | [**Original Project**](https://github.com/protectai/llm-guard) | [**Getting Started**](./docs/get_started/quickstart.md)
|
|
8
|
+
|
|
9
|
+
[](https://GitHub.com/protectai/llm-guard/stargazers/)
|
|
11
|
+
[](http://opensource.org/licenses/MIT)
|
|
12
|
+
[](https://github.com/psf/black)
|
|
13
|
+
[](https://pypi.org/project/llm-guard)
|
|
14
|
+
[](https://pepy.tech/project/llm-guard)
|
|
15
|
+
[](https://pepy.tech/project/llm-guard)
|
|
16
|
+
|
|
17
|
+
<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>
|
|
18
|
+
|
|
19
|
+
## What is LLM Guard?
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
By offering sanitization, detection of harmful language, prevention of data leakage, and resistance against prompt
|
|
24
|
+
injection attacks, LLM-Guard ensures that your interactions with LLMs remain safe and secure.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Begin your journey with LLM Guard Rails by downloading the package:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
# Coming soon to PyPI as llm-guardrails
|
|
32
|
+
pip install llm-guard
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or install from source:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
git clone https://github.com/Nikhilsinghbora/llm-guardrails.git
|
|
39
|
+
cd llm-guardrails
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
**Important Notes**:
|
|
46
|
+
|
|
47
|
+
- LLM Guard Rails is designed for easy integration and deployment in production environments. While it's ready to use
|
|
48
|
+
out-of-the-box, please be informed that we're constantly improving and updating the repository.
|
|
49
|
+
- Base functionality requires a limited number of libraries. As you explore more advanced features, necessary libraries
|
|
50
|
+
will be automatically installed.
|
|
51
|
+
- Ensure you're using Python version 3.10 or higher. Confirm with: `python --version`.
|
|
52
|
+
- We fully support Python 3.10, 3.11, 3.12, 3.13, and 3.14.
|
|
53
|
+
- Library installation issues? Consider upgrading pip: `python -m pip install --upgrade pip`.
|
|
54
|
+
|
|
55
|
+
**Examples**:
|
|
56
|
+
|
|
57
|
+
- Get started with [ChatGPT and LLM Guard](./examples/openai_api.py).
|
|
58
|
+
- Deploy LLM Guard as [API](https://protectai.github.io/llm-guard/api/overview/)
|
|
59
|
+
|
|
60
|
+
## Supported scanners
|
|
61
|
+
|
|
62
|
+
### Prompt scanners
|
|
63
|
+
|
|
64
|
+
- [Anonymize](https://protectai.github.io/llm-guard/input_scanners/anonymize/)
|
|
65
|
+
- [ATRScanner](./docs/input_scanners/atr.md) ⭐ **NEW**
|
|
66
|
+
- [BanCode](./docs/input_scanners/ban_code.md)
|
|
67
|
+
- [BanCompetitors](https://protectai.github.io/llm-guard/input_scanners/ban_competitors/)
|
|
68
|
+
- [BanSubstrings](https://protectai.github.io/llm-guard/input_scanners/ban_substrings/)
|
|
69
|
+
- [BanTopics](https://protectai.github.io/llm-guard/input_scanners/ban_topics/)
|
|
70
|
+
- [Code](https://protectai.github.io/llm-guard/input_scanners/code/)
|
|
71
|
+
- [Gibberish](https://protectai.github.io/llm-guard/input_scanners/gibberish/)
|
|
72
|
+
- [InvisibleText](https://protectai.github.io/llm-guard/input_scanners/invisible_text/)
|
|
73
|
+
- [Language](https://protectai.github.io/llm-guard/input_scanners/language/)
|
|
74
|
+
- [PromptInjection](https://protectai.github.io/llm-guard/input_scanners/prompt_injection/)
|
|
75
|
+
- [Regex](https://protectai.github.io/llm-guard/input_scanners/regex/)
|
|
76
|
+
- [Secrets](https://protectai.github.io/llm-guard/input_scanners/secrets/)
|
|
77
|
+
- [Sentiment](https://protectai.github.io/llm-guard/input_scanners/sentiment/)
|
|
78
|
+
- [TokenLimit](https://protectai.github.io/llm-guard/input_scanners/token_limit/)
|
|
79
|
+
- [Toxicity](https://protectai.github.io/llm-guard/input_scanners/toxicity/)
|
|
80
|
+
|
|
81
|
+
### Output scanners
|
|
82
|
+
|
|
83
|
+
- [ATRScanner](./docs/output_scanners/atr.md) ⭐ **NEW**
|
|
84
|
+
- [BanCode](./docs/output_scanners/ban_code.md)
|
|
85
|
+
- [BanCompetitors](https://protectai.github.io/llm-guard/output_scanners/ban_competitors/)
|
|
86
|
+
- [BanSubstrings](https://protectai.github.io/llm-guard/output_scanners/ban_substrings/)
|
|
87
|
+
- [BanTopics](https://protectai.github.io/llm-guard/output_scanners/ban_topics/)
|
|
88
|
+
- [Bias](https://protectai.github.io/llm-guard/output_scanners/bias/)
|
|
89
|
+
- [Code](https://protectai.github.io/llm-guard/output_scanners/code/)
|
|
90
|
+
- [Deanonymize](https://protectai.github.io/llm-guard/output_scanners/deanonymize/)
|
|
91
|
+
- [JSON](https://protectai.github.io/llm-guard/output_scanners/json/)
|
|
92
|
+
- [Language](https://protectai.github.io/llm-guard/output_scanners/language/)
|
|
93
|
+
- [LanguageSame](https://protectai.github.io/llm-guard/output_scanners/language_same/)
|
|
94
|
+
- [MaliciousURLs](https://protectai.github.io/llm-guard/output_scanners/malicious_urls/)
|
|
95
|
+
- [NoRefusal](https://protectai.github.io/llm-guard/output_scanners/no_refusal/)
|
|
96
|
+
- [ReadingTime](https://protectai.github.io/llm-guard/output_scanners/reading_time/)
|
|
97
|
+
- [FactualConsistency](https://protectai.github.io/llm-guard/output_scanners/factual_consistency/)
|
|
98
|
+
- [Gibberish](https://protectai.github.io/llm-guard/output_scanners/gibberish/)
|
|
99
|
+
- [Regex](https://protectai.github.io/llm-guard/output_scanners/regex/)
|
|
100
|
+
- [Relevance](https://protectai.github.io/llm-guard/output_scanners/relevance/)
|
|
101
|
+
- [Sensitive](https://protectai.github.io/llm-guard/output_scanners/sensitive/)
|
|
102
|
+
- [Sentiment](https://protectai.github.io/llm-guard/output_scanners/sentiment/)
|
|
103
|
+
- [Toxicity](https://protectai.github.io/llm-guard/output_scanners/toxicity/)
|
|
104
|
+
- [URLReachability](https://protectai.github.io/llm-guard/output_scanners/url_reachability/)
|
|
105
|
+
|
|
106
|
+
## Community, Contributing, Docs & Support
|
|
107
|
+
|
|
108
|
+
LLM Guard Rails is an open source solution maintained as an active fork of the original LLM Guard project.
|
|
109
|
+
We are committed to a transparent development process and highly appreciate any contributions.
|
|
110
|
+
Whether you are helping us fix bugs, propose new features, improve our documentation or spread the word,
|
|
111
|
+
we would love to have you as part of our community.
|
|
112
|
+
|
|
113
|
+
### How We Differ
|
|
114
|
+
|
|
115
|
+
- **Active Development**: We maintain and release updates more frequently than the original project
|
|
116
|
+
- **Feature Requests Welcome**: We actively review and implement community feature requests
|
|
117
|
+
- **Responsive Maintenance**: Issues and PRs receive timely reviews and updates
|
|
118
|
+
|
|
119
|
+
### Recent Improvements & Updates
|
|
120
|
+
|
|
121
|
+
**Security & Bug Fixes:**
|
|
122
|
+
- ✅ Fixed CVE-2026-26007: Updated `presidio-anonymizer` to ≥2.2.362
|
|
123
|
+
- ✅ Fixed critical transformers vulnerability (GHSA-phhr-52qp-3mj4)
|
|
124
|
+
- ✅ Fixed Anonymize scanner to properly respect language parameter (#337)
|
|
125
|
+
- ✅ Fixed PromptInjection tokenizer initialization bug (#331)
|
|
126
|
+
- ✅ Fixed MaliciousURLs missing top_k parameter TypeError (#318)
|
|
127
|
+
|
|
128
|
+
**New Features & Enhancements:**
|
|
129
|
+
- ✅ **Python 3.13+ Support**: Full compatibility with Python 3.13 and 3.14
|
|
130
|
+
- ✅ **ATRScanner**: New Agent Threat Rule scanner with 10+ built-in detection patterns
|
|
131
|
+
- ✅ **ThresholdMixin**: Dynamically adjust scanner sensitivity without model reloading
|
|
132
|
+
- ✅ **Model.from_local()**: Factory method for locally-downloaded HuggingFace models
|
|
133
|
+
- ✅ Improved dependency management for better compatibility
|
|
134
|
+
|
|
135
|
+
### Get Involved
|
|
136
|
+
|
|
137
|
+
- Give us a ⭐️ github star ⭐️ on the top of this page to support what we're doing,
|
|
138
|
+
it means a lot for open source projects!
|
|
139
|
+
- Read our
|
|
140
|
+
[docs](./docs/index.md)
|
|
141
|
+
for more info about how to use and customize LLM Guard Rails, and for step-by-step tutorials.
|
|
142
|
+
- Post a [Github Issue](https://github.com/Nikhilsinghbora/llm-guardrails/issues) to submit a bug report, feature request, or suggest an improvement.
|
|
143
|
+
- To contribute to the package, check out our [contribution guidelines](CONTRIBUTING.md), and open a PR.
|
|
144
|
+
|
|
145
|
+
### Support & Contact
|
|
146
|
+
|
|
147
|
+
We're eager to provide personalized assistance and discuss feature requests or improvements.
|
|
148
|
+
|
|
149
|
+
- [Send Email ✉️](mailto:nikhilsinghbora17@gmail.com) - Open to feature requests, improvements, and collaboration
|
|
150
|
+
- [GitHub Issues](https://github.com/Nikhilsinghbora/llm-guardrails/issues) - Report bugs or request features
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
from .input_scanners.base import Scanner as InputScanner
|
|
6
|
+
from .output_scanners.base import Scanner as OutputScanner
|
|
7
|
+
from .util import get_logger
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
This file contains main functionality for scanning both prompts and outputs of Large Language Models (LLMs).
|
|
11
|
+
There are two primary functions: 'scan_prompt' and 'scan_output'.
|
|
12
|
+
Each function takes a list of scanner objects and applies each scanner to the input string(s).
|
|
13
|
+
|
|
14
|
+
An Scanner in this context is an object of a class that inherits from either `input_scanners.Scanner` or `output_scanners.Scanner` base classes.
|
|
15
|
+
These base classes define an `scan` method that takes in a string and returns a processed string and a boolean value indicating the validity of the input string.
|
|
16
|
+
|
|
17
|
+
These functions return the processed string after all scanners have been applied, along with a dictionary mapping the name of each scanner to its validity result.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
LOGGER = get_logger()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def scan_prompt(
|
|
24
|
+
scanners: list[InputScanner], prompt: str, fail_fast: bool = False
|
|
25
|
+
) -> tuple[str, dict[str, bool], dict[str, float]]:
|
|
26
|
+
"""
|
|
27
|
+
Scans a given prompt using the provided scanners.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
scanners: A list of scanner objects. Each scanner should be an instance of a class that inherits from `Scanner`.
|
|
31
|
+
prompt: The input prompt string to be scanned.
|
|
32
|
+
fail_fast: A boolean value indicating whether to stop scanning after the first scanner fails.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
A tuple containing:
|
|
36
|
+
- The processed prompt string after applying all scanners.
|
|
37
|
+
- A dictionary mapping scanner names to boolean values indicating whether the input prompt is valid according to each scanner.
|
|
38
|
+
- A dictionary mapping scanner names to float values of risk scores, where 0 is no risk, and 1 is high risk.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
sanitized_prompt = prompt
|
|
42
|
+
results_valid = {}
|
|
43
|
+
results_score = {}
|
|
44
|
+
|
|
45
|
+
if len(scanners) == 0 or prompt is None or prompt.strip() == "":
|
|
46
|
+
return sanitized_prompt, results_valid, results_score
|
|
47
|
+
|
|
48
|
+
start_time = time.time()
|
|
49
|
+
for scanner in scanners:
|
|
50
|
+
start_time_scanner = time.time()
|
|
51
|
+
sanitized_prompt, is_valid, risk_score = scanner.scan(sanitized_prompt)
|
|
52
|
+
elapsed_time_scanner = time.time() - start_time_scanner
|
|
53
|
+
|
|
54
|
+
LOGGER.debug(
|
|
55
|
+
"Scanner completed",
|
|
56
|
+
scanner=type(scanner).__name__,
|
|
57
|
+
is_valid=is_valid,
|
|
58
|
+
elapsed_time_seconds=round(elapsed_time_scanner, 6),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
results_valid[type(scanner).__name__] = is_valid
|
|
62
|
+
results_score[type(scanner).__name__] = risk_score
|
|
63
|
+
if fail_fast and not is_valid:
|
|
64
|
+
break
|
|
65
|
+
|
|
66
|
+
elapsed_time = time.time() - start_time
|
|
67
|
+
LOGGER.info(
|
|
68
|
+
"Scanned prompt",
|
|
69
|
+
scores=results_score,
|
|
70
|
+
elapsed_time_seconds=round(elapsed_time, 6),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
return sanitized_prompt, results_valid, results_score
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def scan_output(
|
|
77
|
+
scanners: list[OutputScanner], prompt: str, output: str, fail_fast: bool = False
|
|
78
|
+
) -> tuple[str, dict[str, bool], dict[str, float]]:
|
|
79
|
+
"""
|
|
80
|
+
Scans a given output of a large language model using the provided scanners.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
scanners: A list of scanner objects. Each scanner should be an instance of a class that inherits from `Scanner`.
|
|
84
|
+
prompt: The input prompt string that produced the output.
|
|
85
|
+
output: The output string to be scanned.
|
|
86
|
+
fail_fast: A boolean value indicating whether to stop scanning after the first scanner fails.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
A tuple containing:
|
|
90
|
+
- The processed output string after applying all scanners.
|
|
91
|
+
- A dictionary mapping scanner names to boolean values indicating whether the output is valid according to each scanner.
|
|
92
|
+
- A dictionary mapping scanner names to float values of risk scores, where 0 is no risk, and 1 is high risk.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
sanitized_output = output
|
|
96
|
+
results_valid = {}
|
|
97
|
+
results_score = {}
|
|
98
|
+
|
|
99
|
+
if len(scanners) == 0 or output is None or output.strip() == "":
|
|
100
|
+
return sanitized_output, results_valid, results_score
|
|
101
|
+
|
|
102
|
+
start_time = time.time()
|
|
103
|
+
for scanner in scanners:
|
|
104
|
+
start_time_scanner = time.time()
|
|
105
|
+
sanitized_output, is_valid, risk_score = scanner.scan(prompt, sanitized_output)
|
|
106
|
+
elapsed_time_scanner = time.time() - start_time_scanner
|
|
107
|
+
|
|
108
|
+
LOGGER.debug(
|
|
109
|
+
"Scanner completed",
|
|
110
|
+
scanner=type(scanner).__name__,
|
|
111
|
+
is_valid=is_valid,
|
|
112
|
+
elapsed_time_seconds=round(elapsed_time_scanner, 6),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
results_valid[type(scanner).__name__] = is_valid
|
|
116
|
+
results_score[type(scanner).__name__] = risk_score
|
|
117
|
+
if fail_fast and not is_valid:
|
|
118
|
+
break
|
|
119
|
+
|
|
120
|
+
elapsed_time = time.time() - start_time
|
|
121
|
+
LOGGER.info(
|
|
122
|
+
"Scanned output",
|
|
123
|
+
scores=results_score,
|
|
124
|
+
elapsed_time_seconds=round(elapsed_time, 6),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
return sanitized_output, results_valid, results_score
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Input scanners init"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from .anonymize import Anonymize
|
|
5
|
+
from .atr import ATRScanner
|
|
6
|
+
from .ban_code import BanCode
|
|
7
|
+
from .ban_competitors import BanCompetitors
|
|
8
|
+
from .ban_substrings import BanSubstrings
|
|
9
|
+
from .ban_topics import BanTopics
|
|
10
|
+
from .code import Code
|
|
11
|
+
from .emotion_detection import EmotionDetection
|
|
12
|
+
from .gibberish import Gibberish
|
|
13
|
+
from .invisible_text import InvisibleText
|
|
14
|
+
from .language import Language
|
|
15
|
+
from .prompt_injection import PromptInjection
|
|
16
|
+
from .regex import Regex
|
|
17
|
+
from .secrets import Secrets
|
|
18
|
+
from .sentiment import Sentiment
|
|
19
|
+
from .token_limit import TokenLimit
|
|
20
|
+
from .toxicity import Toxicity
|
|
21
|
+
from .util import get_scanner_by_name
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"Anonymize",
|
|
25
|
+
"ATRScanner",
|
|
26
|
+
"BanCode",
|
|
27
|
+
"BanCompetitors",
|
|
28
|
+
"BanSubstrings",
|
|
29
|
+
"BanTopics",
|
|
30
|
+
"Code",
|
|
31
|
+
"EmotionDetection",
|
|
32
|
+
"Gibberish",
|
|
33
|
+
"InvisibleText",
|
|
34
|
+
"Language",
|
|
35
|
+
"PromptInjection",
|
|
36
|
+
"Regex",
|
|
37
|
+
"Secrets",
|
|
38
|
+
"Sentiment",
|
|
39
|
+
"TokenLimit",
|
|
40
|
+
"Toxicity",
|
|
41
|
+
"get_scanner_by_name",
|
|
42
|
+
]
|