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 import error guardrails

Ishaan Jaffb919a1a42e45
diff --git a/litellm/proxy/guardrails/guardrail_helpers.py b/litellm/proxy/guardrails/guardrail_helpers.py
index a57b965c8ea..c351f9f762a 100644
--- a/litellm/proxy/guardrails/guardrail_helpers.py
+++ b/litellm/proxy/guardrails/guardrail_helpers.py
@@ -1,3 +1,5 @@
+import os
+import sys
from typing import Dict
import litellm
@@ -5,6 +7,10 @@ from litellm._logging import verbose_proxy_logger
from litellm.proxy.proxy_server import LiteLLM_TeamTable, UserAPIKeyAuth
from litellm.types.guardrails import *
+sys.path.insert(
+ 0, os.path.abspath("../..")
+) # Adds the parent directory to the system path
+
def can_modify_guardrails(team_obj: Optional[LiteLLM_TeamTable]) -> bool:
if team_obj is None:
diff --git a/litellm/proxy/guardrails/init_guardrails.py b/litellm/proxy/guardrails/init_guardrails.py
index f5ed9fee842..6938a6fc116 100644
--- a/litellm/proxy/guardrails/init_guardrails.py
+++ b/litellm/proxy/guardrails/init_guardrails.py
@@ -113,7 +113,9 @@ def init_guardrails_v2(all_guardrails: dict):
# Init guardrail CustomLoggerClass
if litellm_params["guardrail"] == "aporia":
- from guardrail_hooks.aporia_ai import _ENTERPRISE_Aporia
+ from litellm.proxy.guardrails.guardrail_hooks.aporia_ai import (
+ _ENTERPRISE_Aporia,
+ )
_aporia_callback = _ENTERPRISE_Aporia(
api_base=litellm_params["api_base"],