mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(logging): skip async pre-call dispatch when no async input callbacks are registered
This commit is contained in:
parent
48cf7e0163
commit
6eeb1b1c77
2 changed files with 6 additions and 1 deletions
|
|
@ -2079,7 +2079,8 @@ def client(original_function):
|
|||
else kwargs
|
||||
)
|
||||
try:
|
||||
await logging_obj.async_pre_call()
|
||||
if litellm._async_input_callback:
|
||||
await logging_obj.async_pre_call()
|
||||
result = await original_function(*args, **call_kwargs)
|
||||
except Exception as deployment_error:
|
||||
_deployment_call_end_time = datetime.datetime.now() # noqa: DTZ005 # matches the naive datetimes this whole function already times start_time/end_time with
|
||||
|
|
|
|||
|
|
@ -5298,6 +5298,8 @@ async def test_wrapper_async_awaits_async_input_callback_before_the_provider_cal
|
|||
def sync_callback(kwargs: dict) -> None:
|
||||
events.append(("sync", kwargs["log_event_type"]))
|
||||
|
||||
monkeypatch.setattr("litellm.litellm_core_utils.litellm_logging.customLogger", CustomLogger())
|
||||
|
||||
if registration == "manager":
|
||||
litellm.logging_callback_manager.add_litellm_input_callback(async_callback)
|
||||
else:
|
||||
|
|
@ -5344,6 +5346,8 @@ async def test_wrapper_async_skips_async_input_callback_on_cache_hit(
|
|||
def sync_callback(kwargs: dict) -> None:
|
||||
events.append("sync")
|
||||
|
||||
monkeypatch.setattr("litellm.litellm_core_utils.litellm_logging.customLogger", CustomLogger())
|
||||
|
||||
monkeypatch.setattr(litellm, "_async_input_callback", [async_callback])
|
||||
monkeypatch.setattr(litellm, "input_callback", [sync_callback])
|
||||
monkeypatch.setattr(litellm, "cache", Cache(type="local"))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue