diff --git a/litellm/proxy/guardrails/guardrail_hooks/pangea/pangea.py b/litellm/proxy/guardrails/guardrail_hooks/pangea/pangea.py index 3f36e175461..55c7e72c36f 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/pangea/pangea.py +++ b/litellm/proxy/guardrails/guardrail_hooks/pangea/pangea.py @@ -250,10 +250,13 @@ class PangeaHandler(CustomGuardrail): if isinstance(response, TextCompletionResponse): # Assume the earlier call type as well input_messages = _TextCompletionRequest(data).get_messages() - if not isinstance(response, ModelResponse): - return + elif isinstance(response, ModelResponse): + messages = data.get("messages") + if messages is None: + return # No messages to check + input_messages = cast(List[Dict[Any, Any]], messages) else: - input_messages = cast(List[Dict[Any, Any]], data.get("messages")) + return if choices := response.get("choices"): if isinstance(choices, list):