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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
address greptile review feedback (greploop iteration 1)
yuneng-jiang235d60eb8852
diff --git a/litellm/proxy/db/db_spend_update_writer.py b/litellm/proxy/db/db_spend_update_writer.pyindex c87be7ac819..e2d365ee465 100644--- a/litellm/proxy/db/db_spend_update_writer.py+++ b/litellm/proxy/db/db_spend_update_writer.py@@ -659,22 +659,6 @@ class DBSpendUpdateWriter:db_spend_update_transactions = (await self.spend_update_queue.flush_and_get_aggregated_db_spend_update_transactions())- if any(- len(v) > 0- for v in db_spend_update_transactions.values()- if isinstance(v, dict)- ):- verbose_proxy_logger.info(- "Spend tracking - committing spend updates to DB (no Redis buffer): "- "keys=%d, users=%d, teams=%d, orgs=%d, end_users=%d, team_members=%d, tags=%d",- len(db_spend_update_transactions.get("key_list_transactions") or {}),- len(db_spend_update_transactions.get("user_list_transactions") or {}),- len(db_spend_update_transactions.get("team_list_transactions") or {}),- len(db_spend_update_transactions.get("org_list_transactions") or {}),- len(db_spend_update_transactions.get("end_user_list_transactions") or {}),- len(db_spend_update_transactions.get("team_member_list_transactions") or {}),- len(db_spend_update_transactions.get("tag_list_transactions") or {}),- )await self._commit_spend_updates_to_db(prisma_client=prisma_client,n_retry_times=n_retry_times,diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 78730ee9d60..1983a601e13 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -1771,10 +1771,11 @@ async def update_cache( # noqa: PLR0915verbose_proxy_logger.warning("Spend tracking - failed to update user spend in cache. ""Budget enforcement may use stale spend values. "- "user_id=%s, response_cost=%s - %s",+ "user_id=%s, response_cost=%s - %s\n%s",user_id,response_cost,str(e),+ traceback.format_exc(),)### UPDATE END-USER SPEND ###@@ -1814,10 +1815,11 @@ async def update_cache( # noqa: PLR0915verbose_proxy_logger.warning("Spend tracking - failed to update end user spend in cache. ""Budget enforcement may use stale spend values. "- "end_user_id=%s, response_cost=%s - %s",+ "end_user_id=%s, response_cost=%s - %s\n%s",end_user_id,response_cost,str(e),+ traceback.format_exc(),)### UPDATE TEAM SPEND ###@@ -1861,10 +1863,11 @@ async def update_cache( # noqa: PLR0915verbose_proxy_logger.warning("Spend tracking - failed to update team spend in cache. ""Budget enforcement may use stale spend values. "- "team_id=%s, response_cost=%s - %s",+ "team_id=%s, response_cost=%s - %s\n%s",team_id,response_cost,str(e),+ traceback.format_exc(),)### UPDATE TAG SPEND ###@@ -1912,10 +1915,11 @@ async def update_cache( # noqa: PLR0915verbose_proxy_logger.warning("Spend tracking - failed to update tag spend in cache. ""Budget enforcement may use stale spend values. "- "tags=%s, response_cost=%s - %s",+ "tags=%s, response_cost=%s - %s\n%s",tags,response_cost,str(e),+ traceback.format_exc(),)if token is not None and response_cost is not None: