From ebb5490d3c5566ae8a9524ce3a972242d677ef87 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Tue, 9 Jan 2024 14:56:43 +0530 Subject: [PATCH] (fix) prisma setup --- litellm/proxy/proxy_server.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index c63fac29118..e93c9baf119 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -304,7 +304,7 @@ async def user_api_key_auth( def prisma_setup(database_url: Optional[str]): global prisma_client, proxy_logging_obj, user_api_key_cache - verbose_proxy_logger.debug(f"prisma_setup: {database_url}") + if database_url is not None: try: prisma_client = PrismaClient( @@ -776,7 +776,6 @@ class ProxyConfig: verbose_proxy_logger.debug(f"GOING INTO LITELLM.GET_SECRET!") database_url = litellm.get_secret(database_url) verbose_proxy_logger.debug(f"RETRIEVED DB URL: {database_url}") - ## COST TRACKING ## cost_tracking() ### MASTER KEY ### @@ -1150,6 +1149,15 @@ async def startup_event(): global prisma_client, master_key, use_background_health_checks, llm_router, llm_model_list, general_settings import json + ### LOAD MASTER KEY ### + # check if master key set in environment - load from there + master_key = litellm.get_secret("LITELLM_MASTER_KEY", None) + + ### CONNECT TO DB ### + # check if DATABASE_URL in environment - load from there + if prisma_client is None: + prisma_setup(database_url=os.getenv("DATABASE_URL")) + ### LOAD CONFIG ### worker_config = litellm.get_secret("WORKER_CONFIG") verbose_proxy_logger.debug(f"worker_config: {worker_config}") @@ -1169,15 +1177,6 @@ async def startup_event(): # if not, assume it's a json string worker_config = json.loads(os.getenv("WORKER_CONFIG")) await initialize(**worker_config) - ### LOAD MASTER KEY ### - # check if master key set in environment - load from there - master_key = litellm.get_secret("LITELLM_MASTER_KEY", None) - - ### CONNECT TO DB ### - # check if DATABASE_URL in environment - load from there - if prisma_client is None: - prisma_setup(database_url=os.getenv("DATABASE_URL")) - proxy_logging_obj._init_litellm_callbacks() # INITIALIZE LITELLM CALLBACKS ON SERVER STARTUP <- do this to catch any logging errors on startup, not when calls are being made if use_background_health_checks: