litellm/litellm
Ishaan Jaff d17bf84f84
feat: EU AI Act Article 5 policy template for prohibited practices detection (#21342)
* Add 6 new EU PII patterns for GDPR compliance

- fr_nir: French Social Security Number (NIR/INSEE) with validation
- eu_iban_enhanced: Enhanced IBAN detection with specific format
- fr_phone: French phone numbers (+33, 0033, 0 formats)
- eu_vat: EU VAT identification numbers (all 27 member states)
- eu_passport_generic: Generic EU passport format
- fr_postal_code: French postal codes with contextual keywords

* Add GDPR Art. 32 EU PII Protection policy template

- Comprehensive GDPR Article 32 compliance policy
- 4 guardrail groups: National IDs, Financial, Contact Info, Business IDs
- Masks French NIR/INSEE, EU IBANs, French phones, EU VAT numbers
- Includes EU passport numbers and email addresses
- Medium complexity template with indigo icon

* Add comprehensive tests for EU PII patterns

- Test French NIR validation (sex digit, month range)
- Test enhanced IBAN detection (French, German)
- Test French phone number formats
- Test EU VAT numbers
- Test generic EU passport format
- Test French postal code pattern

* Add EU pattern loading and category validation tests

- Verify all 6 EU PII patterns are loaded correctly
- Verify patterns are categorized as 'EU PII Patterns'
- Ensure pattern loading consistency

* Add end-to-end tests for GDPR policy template

- 4 tests for PII that should be masked (NIR, IBAN, phone, VAT)
- 4 tests for text that should pass through (invalid patterns, no PII)
- 1 bonus test for multiple PII types in same message
- All tests verify correct masking behavior

* Add region field to policy templates

- Added region field to all 6 templates (EU, AU, Global)
- Updated both main and backup JSON files
- Enables region-based filtering in UI

* Add region filter to policy templates UI

- Added Radio.Group filter for regions (All, AU, EU, Global)
- Efficient filtering with useMemo hooks
- Clean button-based UI matching existing design
- Defaults missing regions to Global

* feat: add EU AI Act Article 5 policy template

Add policy template for detecting EU AI Act Article 5 prohibited practices using conditional keyword matching.

Coverage:
- Article 5.1.c: Social scoring systems
- Article 5.1.f: Emotion recognition in workplace/education
- Article 5.1.h: Biometric categorization of protected characteristics
- Article 5.1.a: Harmful manipulation techniques
- Article 5.1.b: Vulnerability exploitation

Implementation:
- Uses proven conditional matching pattern (identifier + block words)
- 10 always-block keywords for explicit violations
- 8 exceptions for research/compliance/entertainment
- Zero cost (<5ms), no external APIs, 100% private

* feat: add EU AI Act guardrail config example

Example configuration showing how to enable EU AI Act Article 5 guardrail.

* test: add 40 test cases for EU AI Act Article 5

Comprehensive test coverage:
- 10 always-block keywords (explicit violations)
- 15 conditional matches (identifier + block word)
- 8 exceptions (research, compliance, entertainment)
- 7 no-match cases (legitimate uses)

Tests validate correct blocking/allowing behavior for Article 5 prohibited practices.

* Fix: support standalone conditional matching without inherit_from

- Updated loading logic to activate conditional matching when either:
  1. identifier_words + inherit_from (existing pattern)
  2. identifier_words + additional_block_words (new standalone pattern)
- Modified _load_conditional_category to handle standalone templates
- EU AI Act template now works properly without inherit_from
- All 45 tests passing

Fixes Greptile feedback: conditional matching now activates for templates
that define additional_block_words without requiring inherit_from

* fix: address Greptile code review feedback (2/5 score)

- patterns.json: add keyword_pattern to eu_vat and eu_passport_generic
- patterns.json: fix fr_phone pattern with leading word boundary
- patterns.json: fix eu_iban_enhanced regex efficiency
- policy_templates.json: remove country-specific passport patterns from GDPR template
- policy_templates_backup.json: sync with main templates file
- test_gdpr_policy_e2e.py: update test setup and fix VAT test text

All tests now pass. Keyword guards prevent false positives.

* Fix: address Greptile pattern feedback

- Fix fr_phone: use negative lookbehind (?<!\d) to prevent false matches in digit strings
- Add keyword_pattern to eu_passport_generic to reduce false positives
- Add keyword_pattern to eu_vat for contextual matching

All pattern tests passing

* Update litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/patterns.json

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-16 15:33:07 -08:00
..
a2a_protocol fix(mypy): resolve type checking errors in 5 files (#20627) 2026-02-06 18:34:55 -08:00
anthropic_interface [bug fix] do not fallback to token counter if disable_token_counter is enabled (#19041) 2026-01-13 16:53:38 -08:00
assistants
batch_completion fix(batch_completion): submit all model futures before waiting (#20705) 2026-02-11 15:44:37 +05:30
batches fix mypy 2026-02-16 19:05:06 +05:30
caching fix(cache): prevent DualCache async batch check-then-act race (#20986) 2026-02-13 18:32:41 +05:30
completion_extras fix openai tests 2026-02-12 17:53:47 -08:00
containers Make keepalive_timeout parameter work for Gunicorn (#19087) 2026-01-16 03:32:59 +05:30
endpoints/speech/speech_to_completion_bridge
experimental_mcp_client fix(mcp): resolve OAuth2 'Capabilities: none' bug for upstream MCP servers (#20602) 2026-02-06 15:00:35 -08:00
files fix(mypy): fix type errors in files, opentelemetry, gemini transformation, and key management (#20161) 2026-01-31 10:09:07 -08:00
fine_tuning
google_genai Add custom vertex ai mapping to the output 2026-01-22 15:18:24 +05:30
images Add None as default image value 2026-01-19 09:08:38 +05:30
integrations Add GDPR Art. 32 EU PII Protection Policy Template (#21340) 2026-02-16 15:28:46 -08:00
interactions [Feat] Interactions API - allow using all litellm providers (interactions -> responses api bridge) (#18373) 2025-12-23 22:30:22 +05:30
litellm_core_utils Agent Guardrails - on streaming output (#21206) 2026-02-14 11:36:52 -08:00
llms Fix: Exclude tool params for models without function calling support (#21125) (#21244) 2026-02-16 08:36:32 -08:00
ocr [Feat] /ocr - Add VertexAI OCR provider support + cost tracking (#16216) 2025-11-03 15:56:49 -08:00
passthrough [Fix] VertexAI Pass through - Ensure only anthropic betas are forwarded down to LLM API (#19542) 2026-01-21 19:12:04 -08:00
proxy feat: EU AI Act Article 5 policy template for prohibited practices detection (#21342) 2026-02-16 15:33:07 -08:00
proxy_auth Fix mypy issues 2026-02-05 09:44:05 +05:30
rag fix(ci): Fix ruff lint error - unused import in vertex_ai_ingestion (#21178) 2026-02-13 18:14:23 -08:00
realtime_api [Feat] Add xAI /realtime API Support - works with LiveKitSDK (#20381) 2026-02-03 19:58:28 -08:00
rerank_api Add tests for header forwarding 2025-12-12 17:54:17 +05:30
responses fix: remove unused Reasoning import from transformation.py 2026-02-15 12:37:41 -03:00
router_strategy fix(router): remove repeated provider parsing in budget limiter hot path (#21043) 2026-02-12 20:05:55 -08:00
router_utils feat: add support for anthropic_messages call type in prompt caching (#19233) 2026-02-07 22:51:06 -08:00
search
secret_managers Fix authorization issues, same alias; verified working 2026-02-05 14:14:20 +05:30
skills [Feat] Unified Skills API - works across Anthropic, Vertex, Azure, Bedrock (#18232) 2025-12-19 18:55:59 +05:30
types Add GDPR Art. 32 EU PII Protection Policy Template (#21340) 2026-02-16 15:28:46 -08:00
vector_store_files Vector store files Stable Release (#16643) 2025-11-15 13:00:33 -08:00
vector_stores Fix vector store configuration synchronization failure 2025-12-05 11:46:14 +05:30
videos fix: respect videos content db creds 2025-12-10 23:00:01 +05:30
__init__.py Add support sync with remote URL for beta headers 2026-02-13 15:49:42 +05:30
_lazy_imports.py refactor: migrate utils.py lazy imports to registry pattern (#18657) 2026-01-05 09:55:48 -08:00
_lazy_imports_registry.py fix: remove duplicate PerplexityResponsesConfig from LLM_CONFIG_NAMES (#21105) 2026-02-13 08:38:50 -08:00
_logging.py fix:Parse embedded JSON in the message field of logs (#20366) 2026-02-10 16:13:33 +05:30
_redis.py
_service_logger.py Add comments 2026-02-14 19:46:56 -05:00
_uuid.py
_version.py
anthropic_beta_headers_config.json Merge branch 'main' into litellm_litellm_anthropic_remote_url3 2026-02-13 18:40:00 +05:30
anthropic_beta_headers_manager.py Add support sync with remote URL for beta headers 2026-02-13 15:49:42 +05:30
budget_manager.py
constants.py Merge pull request #20321 from Harshit28j/litellm_fix-virtual-key-grace-period 2026-02-16 19:36:18 +05:30
cost.json
cost_calculator.py fix mypy 2026-02-16 18:55:21 +05:30
exceptions.py Fix unsafe access to request attribute (#19573) 2026-01-22 10:58:29 -08:00
main.py feat(vertex_ai): preserve usageMetadata in _hidden_params (#20559) 2026-02-12 20:44:59 -08:00
model_prices_and_context_window_backup.json Fix au.anthropic.claude opus 4 6 v1 (#20731) 2026-02-16 14:15:37 -08:00
mypy.ini
policy_templates_backup.json Add GDPR Art. 32 EU PII Protection Policy Template (#21340) 2026-02-16 15:28:46 -08:00
py.typed
router.py Merge pull request #21089 from BerriAI/litellm_vector_store_endpoints 2026-02-13 22:18:29 +05:30
scheduler.py fix(scheduler): remove orphan entries from queue - causing memory leak. (#20866) 2026-02-10 22:34:52 -08:00
timeout.py
utils.py Merge branch 'main' into litellm_oss_staging_02_11_2026 2026-02-12 20:04:46 +05:30