Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/guardrails/guardrail_hooks/promptguard/__init__.py: 57%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
1from typing import TYPE_CHECKING, Final
3from litellm.types.guardrails import SupportedGuardrailIntegrations
5from .promptguard import PromptGuardGuardrail
7if TYPE_CHECKING: 7 ↛ 8line 7 didn't jump to line 8 because the condition on line 7 was never true
8 from litellm.types.guardrails import Guardrail, LitellmParams
11def initialize_guardrail(
12 litellm_params: "LitellmParams",
13 guardrail: "Guardrail",
14):
15 import litellm
17 _cb: Final = PromptGuardGuardrail(
18 api_base=litellm_params.api_base,
19 api_key=litellm_params.api_key,
20 block_on_error=litellm_params.block_on_error,
21 guardrail_name=guardrail.get(
22 "guardrail_name",
23 "",
24 ),
25 event_hook=litellm_params.mode,
26 default_on=litellm_params.default_on,
27 )
28 litellm.logging_callback_manager.add_litellm_callback(
29 _cb,
30 )
32 return _cb
35guardrail_initializer_registry: Final = {
36 SupportedGuardrailIntegrations.PROMPTGUARD.value: initialize_guardrail,
37}
40guardrail_class_registry: Final = {
41 SupportedGuardrailIntegrations.PROMPTGUARD.value: PromptGuardGuardrail,
42}