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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix MYPY linting + JSON refs
Ishaan Jaffer1e257db0a5a5
diff --git a/litellm/proxy/policy_engine/policy_registry.py b/litellm/proxy/policy_engine/policy_registry.pyindex 50acddd2b9d..1ca6062e5ac 100644--- a/litellm/proxy/policy_engine/policy_registry.py+++ b/litellm/proxy/policy_engine/policy_registry.py@@ -7,11 +7,10 @@ Policies define WHAT guardrails to apply. WHERE they apply is definedby policy_attachments (see AttachmentRegistry)."""+import jsonfrom datetime import datetime, timezonefrom typing import TYPE_CHECKING, Any, Dict, List, Optional-from prisma import Json as PrismaJson-from litellm._logging import verbose_proxy_loggerfrom litellm.types.proxy.policy_engine import (GuardrailPipeline,@@ -250,10 +249,10 @@ class PolicyRegistry:data["created_by"] = created_bydata["updated_by"] = created_byif policy_request.condition is not None:- data["condition"] = PrismaJson(policy_request.condition.model_dump())+ data["condition"] = json.dumps(policy_request.condition.model_dump())if policy_request.pipeline is not None:validated_pipeline = GuardrailPipeline(**policy_request.pipeline)- data["pipeline"] = PrismaJson(validated_pipeline.model_dump())+ data["pipeline"] = json.dumps(validated_pipeline.model_dump())created_policy = await prisma_client.db.litellm_policytable.create(data=data@@ -332,10 +331,10 @@ class PolicyRegistry:if policy_request.guardrails_remove is not None:update_data["guardrails_remove"] = policy_request.guardrails_removeif policy_request.condition is not None:- update_data["condition"] = PrismaJson(policy_request.condition.model_dump())+ update_data["condition"] = json.dumps(policy_request.condition.model_dump())if policy_request.pipeline is not None:validated_pipeline = GuardrailPipeline(**policy_request.pipeline)- update_data["pipeline"] = PrismaJson(validated_pipeline.model_dump())+ update_data["pipeline"] = json.dumps(validated_pipeline.model_dump())updated_policy = await prisma_client.db.litellm_policytable.update(where={"policy_id": policy_id},