mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-07-10 20:53:42 +02:00
fix import issues
This commit is contained in:
committed by
Hemang
parent
78d3bc9c14
commit
2a66582c7c
@@ -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]")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user