(minor latency fixes / proxy) - use verbose_proxy_logger.debug() instead of litellm.print_verbose (#7664)

* minor latency fixes

* fix code quality
This commit is contained in:
Ishaan Jaff 2025-01-09 21:06:09 -08:00 committed by GitHub
parent 768275f3ce
commit b9dbc70a8e
3 changed files with 8 additions and 14 deletions

View file

@ -4,8 +4,8 @@
from fastapi import HTTPException from fastapi import HTTPException
import litellm
from litellm import verbose_logger from litellm import verbose_logger
from litellm._logging import verbose_proxy_logger
from litellm.caching.caching import DualCache from litellm.caching.caching import DualCache
from litellm.integrations.custom_logger import CustomLogger from litellm.integrations.custom_logger import CustomLogger
from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy._types import UserAPIKeyAuth
@ -16,10 +16,6 @@ class _PROXY_CacheControlCheck(CustomLogger):
def __init__(self): def __init__(self):
pass pass
def print_verbose(self, print_statement):
if litellm.set_verbose is True:
print(print_statement) # noqa
async def async_pre_call_hook( async def async_pre_call_hook(
self, self,
user_api_key_dict: UserAPIKeyAuth, user_api_key_dict: UserAPIKeyAuth,
@ -28,7 +24,7 @@ class _PROXY_CacheControlCheck(CustomLogger):
call_type: str, call_type: str,
): ):
try: try:
self.print_verbose("Inside Cache Control Check Pre-Call Hook") verbose_proxy_logger.debug("Inside Cache Control Check Pre-Call Hook")
allowed_cache_controls = user_api_key_dict.allowed_cache_controls allowed_cache_controls = user_api_key_dict.allowed_cache_controls
if data.get("cache", None) is None: if data.get("cache", None) is None:

View file

@ -1,7 +1,7 @@
from fastapi import HTTPException from fastapi import HTTPException
import litellm
from litellm import verbose_logger from litellm import verbose_logger
from litellm._logging import verbose_proxy_logger
from litellm.caching.caching import DualCache from litellm.caching.caching import DualCache
from litellm.integrations.custom_logger import CustomLogger from litellm.integrations.custom_logger import CustomLogger
from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy._types import UserAPIKeyAuth
@ -12,10 +12,6 @@ class _PROXY_MaxBudgetLimiter(CustomLogger):
def __init__(self): def __init__(self):
pass pass
def print_verbose(self, print_statement):
if litellm.set_verbose is True:
print(print_statement) # noqa
async def async_pre_call_hook( async def async_pre_call_hook(
self, self,
user_api_key_dict: UserAPIKeyAuth, user_api_key_dict: UserAPIKeyAuth,
@ -24,7 +20,7 @@ class _PROXY_MaxBudgetLimiter(CustomLogger):
call_type: str, call_type: str,
): ):
try: try:
self.print_verbose("Inside Max Budget Limiter Pre-Call Hook") verbose_proxy_logger.debug("Inside Max Budget Limiter Pre-Call Hook")
cache_key = f"{user_api_key_dict.user_id}_user_api_key_user_id" cache_key = f"{user_api_key_dict.user_id}_user_api_key_user_id"
user_row = await cache.async_get_cache( user_row = await cache.async_get_cache(
cache_key, parent_otel_span=user_api_key_dict.parent_otel_span cache_key, parent_otel_span=user_api_key_dict.parent_otel_span

View file

@ -472,8 +472,8 @@ class ProxyLogging:
2. /embeddings 2. /embeddings
3. /image/generation 3. /image/generation
""" """
print_verbose("Inside Proxy Logging Pre-call hook!") verbose_proxy_logger.debug("Inside Proxy Logging Pre-call hook!")
### ALERTING ### ## ALERTING ###
asyncio.create_task( asyncio.create_task(
self.slack_alerting_instance.response_taking_too_long(request_data=data) self.slack_alerting_instance.response_taking_too_long(request_data=data)
) )
@ -517,6 +517,8 @@ class ProxyLogging:
_callback is not None _callback is not None
and isinstance(_callback, CustomLogger) and isinstance(_callback, CustomLogger)
and "async_pre_call_hook" in vars(_callback.__class__) and "async_pre_call_hook" in vars(_callback.__class__)
and _callback.__class__.async_pre_call_hook
!= CustomLogger.async_pre_call_hook
): ):
response = await _callback.async_pre_call_hook( response = await _callback.async_pre_call_hook(
user_api_key_dict=user_api_key_dict, user_api_key_dict=user_api_key_dict,