From d7ca5c4faee6efd2644f70df6af4cda1505f161f Mon Sep 17 00:00:00 2001 From: Ashton Sidhu Date: Thu, 28 May 2026 16:15:34 -0400 Subject: [PATCH] Don't scan images --- .../guardrail_hooks/hiddenlayer/hiddenlayer.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py index a6ea2e09583..5357be2deb3 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py +++ b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py @@ -263,6 +263,18 @@ class HiddenlayerGuardrail(CustomGuardrail): if scan_params := inputs.get("structured_messages"): last_msg: Final = scan_params[-1] + content = last_msg.get("content") + scan_contents = [] + + # Remove images from multimodal content before sending to HiddenLayer v1 + if content and isinstance(content, list): + for item in content: + if isinstance(item, dict) and not item.get("type") == "image_url": + scan_contents.append(item) + effective_content: Final = str(scan_contents) if scan_contents else "" + else: + effective_content: Final = str(content or "") + result: _HiddenlayerResponse = await self._call_hiddenlayer( project_id, hl_request_metadata, @@ -270,7 +282,7 @@ class HiddenlayerGuardrail(CustomGuardrail): "messages": [ { "role": last_msg.get("role", "user"), - "content": str(last_msg.get("content", "")), + "content": effective_content } ] },