Skip to content

Commit bfe69af

Browse files
committed
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)
1 parent 19395bf commit bfe69af

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize_guardrail(
1717
_cb = PromptGuardGuardrail(
1818
api_base=litellm_params.api_base,
1919
api_key=litellm_params.api_key,
20-
block_on_error=getattr(litellm_params, "block_on_error", None),
20+
block_on_error=litellm_params.block_on_error,
2121
guardrail_name=guardrail.get(
2222
"guardrail_name",
2323
"",

litellm/proxy/guardrails/guardrail_hooks/promptguard/promptguard.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,8 @@ async def apply_guardrail(
186186
if structured_messages:
187187
inputs["structured_messages"] = redacted
188188
if "texts" in inputs:
189-
extracted = (
190-
self._extract_texts_from_messages(
191-
redacted,
192-
)
189+
extracted = self._extract_texts_from_messages(
190+
redacted,
193191
)
194192
if extracted:
195193
inputs["texts"] = extracted

litellm/types/guardrails.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from litellm.types.proxy.guardrails.guardrail_hooks.litellm_content_filter import (
2121
ContentFilterCategoryConfig,
2222
)
23+
from litellm.types.proxy.guardrails.guardrail_hooks.promptguard import (
24+
PromptGuardConfigModel,
25+
)
2326
from litellm.types.proxy.guardrails.guardrail_hooks.qualifire import (
2427
QualifireGuardrailConfigModel,
2528
)
@@ -736,6 +739,7 @@ class LitellmParams(
736739
PillarGuardrailConfigModel,
737740
GraySwanGuardrailConfigModel,
738741
NomaGuardrailConfigModel,
742+
PromptGuardConfigModel,
739743
ToolPermissionGuardrailConfigModel,
740744
ZscalerAIGuardConfigModel,
741745
JavelinGuardrailConfigModel,

0 commit comments

Comments
 (0)