Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/guardrails/guardrail_hooks/xecguard/__init__.py: 57%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 12:01 +0000

1from typing import TYPE_CHECKING, Final 

2 

3from litellm.types.guardrails import SupportedGuardrailIntegrations 

4 

5from .xecguard import XecGuardGuardrail 

6 

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 

9 

10 

11def initialize_guardrail( 

12 litellm_params: "LitellmParams", 

13 guardrail: "Guardrail", 

14): 

15 import litellm 

16 

17 _cb: Final = XecGuardGuardrail( 

18 api_base=litellm_params.api_base, 

19 api_key=litellm_params.api_key, 

20 xecguard_model=litellm_params.xecguard_model, 

21 policy_names=litellm_params.policy_names, 

22 block_on_error=litellm_params.block_on_error, 

23 grounding_strictness=litellm_params.grounding_strictness, 

24 guardrail_name=guardrail.get( 

25 "guardrail_name", 

26 "", 

27 ), 

28 event_hook=litellm_params.mode, 

29 default_on=litellm_params.default_on, 

30 ) 

31 litellm.logging_callback_manager.add_litellm_callback( 

32 _cb, 

33 ) 

34 

35 return _cb 

36 

37 

38guardrail_initializer_registry: Final = { 

39 SupportedGuardrailIntegrations.XECGUARD.value: initialize_guardrail, 

40} 

41 

42 

43guardrail_class_registry: Final = { 

44 SupportedGuardrailIntegrations.XECGUARD.value: XecGuardGuardrail, 

45}