From eb24ce25ea6bdd93eb2766afbdf157824222b222 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 25 Oct 2024 16:48:25 +0400 Subject: [PATCH] fix create_audit_log_for_update --- .../proxy/management_helpers/audit_logs.py | 2 +- litellm/proxy/proxy_config.yaml | 2 +- litellm/proxy/proxy_server.py | 32 ------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/litellm/proxy/management_helpers/audit_logs.py b/litellm/proxy/management_helpers/audit_logs.py index 27da9911a6e..b023e909650 100644 --- a/litellm/proxy/management_helpers/audit_logs.py +++ b/litellm/proxy/management_helpers/audit_logs.py @@ -28,7 +28,7 @@ async def create_audit_log_for_update(request_data: LiteLLM_AuditLogs): if isinstance(request_data.before_value, dict): request_data.before_value = json.dumps(request_data.before_value) - _request_data = request_data.dict(exclude_none=True) + _request_data = request_data.model_dump(exclude_none=True) try: await prisma_client.db.litellm_auditlog.create( diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 8f22d0d780c..18cc262b454 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -13,7 +13,7 @@ general_settings: proxy_batch_write_at: 60 # Batch write spend updates every 60s litellm_settings: - success_callback: ["langfuse"] + store_audit_logs: true # https://docs.litellm.ai/docs/proxy/reliability#default-fallbacks default_fallbacks: ["gpt-4o-2024-08-06", "claude-3-5-sonnet-20240620"] diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 26ff04d873b..7918543b7f3 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6434,38 +6434,6 @@ async def list_end_user( return returned_response -async def create_audit_log_for_update(request_data: LiteLLM_AuditLogs): - if premium_user is not True: - return - - if litellm.store_audit_logs is not True: - return - if prisma_client is None: - raise Exception("prisma_client is None, no DB connected") - - verbose_proxy_logger.debug("creating audit log for %s", request_data) - - if isinstance(request_data.updated_values, dict): - request_data.updated_values = json.dumps(request_data.updated_values) - - if isinstance(request_data.before_value, dict): - request_data.before_value = json.dumps(request_data.before_value) - - _request_data = request_data.dict(exclude_none=True) - - try: - await prisma_client.db.litellm_auditlog.create( - data={ - **_request_data, # type: ignore - } - ) - except Exception as e: - # [Non-Blocking Exception. Do not allow blocking LLM API call] - verbose_proxy_logger.error(f"Failed Creating audit log {e}") - - return - - #### BUDGET TABLE MANAGEMENT ####