Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix mypy issues

Sameer Kankutedec630b36558
diff --git a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/__init__.py
index d85e52a05e3..cd71d55991e 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/__init__.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/__init__.py
@@ -17,6 +17,7 @@ def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"
litellm_params.version if hasattr(litellm_params, "version") else None
)
+ _hiddenlayer_callback: HiddenlayerGuardrail | HiddenlayerGuardrailV2
if not version or version < 2:
_hiddenlayer_callback = HiddenlayerGuardrail(
api_base=litellm_params.api_base,
diff --git a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py
index 9ea93fa667b..091187983a2 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/hiddenlayer/hiddenlayer.py
@@ -386,6 +386,7 @@ class HiddenlayerGuardrailV2(CustomGuardrail):
if "hl-requester-id" not in hl_headers:
hl_headers["hl-requester-id"] = "LiteLLM"
+ payload: Any
if input_type == "request":
payload = {
"messages": inputs.get("structured_messages"),
@@ -414,7 +415,7 @@ class HiddenlayerGuardrailV2(CustomGuardrail):
payload = {}
response = await self._call_hiddenlayer(
- payload, input_type, hl_headers # ty:ignore[invalid-argument-type]
+ payload, input_type, hl_headers
)
output = response.json()
@@ -457,7 +458,7 @@ class HiddenlayerGuardrailV2(CustomGuardrail):
async def _call_hiddenlayer(
self,
- payload: dict[str, Any],
+ payload: Any,
input_type: Literal["request", "response"],
hl_headers: dict[str, str],
) -> httpx.Response: