This commit is contained in:
Maha Rana Yadavalli 2026-10-20 19:21:54 +00:00 • committed by GitHub
commit 131ee6774f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -405,7 +405,7 @@ def initialize_callbacks_on_proxy(
PrometheusLogger._mount_metrics_endpoint()
else:
litellm.callbacks = [
litellm.callbacks.append(
_loaded_callback_or_raise(
entry=value,
loaded=get_instance_fn(
@ -413,7 +413,7 @@ def initialize_callbacks_on_proxy(
config_file_path=config_file_path,
),
)
]
)
verbose_proxy_logger.debug("%s Initialized Callbacks - %s %s", blue_color_code, litellm.callbacks, reset_color_code)

View file

@ -762,3 +762,15 @@ def test_initialize_callbacks_on_proxy_accepts_instance_non_list_value(probe_con
assert len(litellm.callbacks) == 1
assert isinstance(litellm.callbacks[0], CustomLogger)
@pytest.mark.parametrize("as_list", [False, True], ids=["string_value", "list_value"])
def test_initialize_callbacks_on_proxy_keeps_previously_registered_callbacks(probe_config_path: str, as_list: bool):
entry: Final = f"{_PROBE_MODULE_NAME}.proxy_handler_instance"
internal_callback: Final = CustomLogger()
litellm.callbacks.append(internal_callback)
_load_callbacks([entry] if as_list else entry, probe_config_path)
assert litellm.callbacks[0] is internal_callback
assert [type(cb).__name__ for cb in litellm.callbacks[1:]] == ["FloorMaxTokens"]