From 20a57507f5951259e5ba5966eb128ad561e2901a Mon Sep 17 00:00:00 2001 From: Abhijoy Sarkar Date: Sat, 21 Mar 2026 11:31:24 +0530 Subject: [PATCH] Fix CI lint: black formatting, add PromptGuardConfigModel to LitellmParams - Reformat promptguard.py to match CI black version (parenthesization) - Add PromptGuardConfigModel as base class of LitellmParams for proper Pydantic schema validation, consistent with all other guardrail vendors - Use litellm_params.block_on_error directly (now a typed field) --- .../guardrails/guardrail_hooks/promptguard/__init__.py | 2 +- .../guardrails/guardrail_hooks/promptguard/promptguard.py | 6 ++---- litellm/types/guardrails.py | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py index a3179cc5ed7..50b795f93df 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py +++ b/litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py @@ -17,7 +17,7 @@ def initialize_guardrail( _cb = PromptGuardGuardrail( api_base=litellm_params.api_base, api_key=litellm_params.api_key, - block_on_error=getattr(litellm_params, "block_on_error", None), + block_on_error=litellm_params.block_on_error, guardrail_name=guardrail.get( "guardrail_name", "", diff --git a/litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py b/litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py index f37e36d2c43..009e29ef089 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py +++ b/litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py @@ -186,10 +186,8 @@ class PromptGuardGuardrail(CustomGuardrail): if structured_messages: inputs["structured_messages"] = redacted if "texts" in inputs: - extracted = ( - self._extract_texts_from_messages( - redacted, - ) + extracted = self._extract_texts_from_messages( + redacted, ) if extracted: inputs["texts"] = extracted diff --git a/litellm/types/guardrails.py b/litellm/types/guardrails.py index 9034dcd251b..9231daa0968 100644 --- a/litellm/types/guardrails.py +++ b/litellm/types/guardrails.py @@ -23,6 +23,9 @@ from litellm.types.proxy.guardrails.guardrail_hooks.akto import ( from litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import ( ContentFilterCategoryConfig, ) +from litellm.types.proxy.guardrails.guardrail_hooks.promptguard import ( + PromptGuardConfigModel, +) from litellm.types.proxy.guardrails.guardrail_hooks.qualifire import ( QualifireGuardrailConfigModel, ) @@ -740,6 +743,7 @@ class LitellmParams( PillarGuardrailConfigModel, GraySwanGuardrailConfigModel, NomaGuardrailConfigModel, + PromptGuardConfigModel, ToolPermissionGuardrailConfigModel, ZscalerAIGuardConfigModel, AktoConfigModel,