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)
This commit is contained in:
Abhijoy Sarkar 2026-03-21 11:31:24 +05:30
parent 67b8eaa1b2
commit 20a57507f5
3 changed files with 7 additions and 5 deletions

View file

@ -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",
"",

View file

@ -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

View file

@ -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,