From 2a66582c7c5951af02e58a541b42a56e19848fb9 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Fri, 28 Mar 2025 19:58:04 +0100 Subject: [PATCH] fix import issues --- gateway/common/config_manager.py | 4 ++-- gateway/serve.py | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/gateway/common/config_manager.py b/gateway/common/config_manager.py index 57a1d89..3e62b55 100644 --- a/gateway/common/config_manager.py +++ b/gateway/common/config_manager.py @@ -4,8 +4,6 @@ import asyncio import os import threading -from integrations.guardails import _preload - from httpx import HTTPStatusError @@ -20,6 +18,8 @@ class GatewayConfig: Loads the guardrails from the file specified in GUARDRAILS_FILE_PATH. Returns the guardrails file content as a string. """ + from integrations.guardrails import _preload + guardrails_file = os.getenv("GUARDRAILS_FILE_PATH", "") if not guardrails_file: print("[warning: GUARDRAILS_FILE_PATH is not set. Using empty guardrails]") diff --git a/gateway/serve.py b/gateway/serve.py index 0d73096..e3683f9 100644 --- a/gateway/serve.py +++ b/gateway/serve.py @@ -2,28 +2,15 @@ import fastapi import uvicorn -from common.config_manager import GatewayConfigManager from routes.anthropic import gateway as anthropic_gateway from routes.gemini import gateway as gemini_gateway from routes.open_ai import gateway as open_ai_gateway from starlette_compress import CompressMiddleware -from contextlib import asynccontextmanager - - -@asynccontextmanager -async def lifespan(app: fastapi.FastAPI): - """Lifespan event to load the config manager""" - gateway_config = GatewayConfigManager.get_config() - yield - # Cleanup if needed - del gateway_config - app = fastapi.app = fastapi.FastAPI( docs_url="/api/v1/gateway/docs", redoc_url="/api/v1/gateway/redoc", openapi_url="/api/v1/gateway/openapi.json", - lifespan=lifespan, ) app.add_middleware(CompressMiddleware)