From 85944a1fef885f75cacb2566ccfb1dcde709ab09 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Mon, 5 Jan 2026 09:20:14 -0800 Subject: [PATCH] feat: lazy load DatadogLLMObsInitParams to reduce import time - Added DatadogLLMObsInitParams to TYPES_NAMES in _lazy_imports_registry.py - Added import map entry for DatadogLLMObsInitParams in _TYPES_IMPORT_MAP - Moved DatadogLLMObsInitParams import from module level to TYPE_CHECKING block in __init__.py - Follows existing lazy import patterns for type classes - Automatically tested by existing test_types_lazy_imports() function --- litellm/__init__.py | 4 +++- litellm/_lazy_imports_registry.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 4f8c57ef442..dfe959bf747 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -26,7 +26,6 @@ from typing import ( overload, Type, ) -from litellm.types.integrations.datadog_llm_obs import DatadogLLMObsInitParams from litellm.types.integrations.datadog import DatadogInitParams from litellm._logging import ( set_verbose, @@ -1533,6 +1532,9 @@ if TYPE_CHECKING: # Custom logger class (lazy-loaded) from litellm.integrations.custom_logger import CustomLogger + # Datadog LLM observability params (lazy-loaded) + from litellm.types.integrations.datadog_llm_obs import DatadogLLMObsInitParams + # Logging callback manager class and instance (lazy-loaded) from litellm.litellm_core_utils.logging_callback_manager import LoggingCallbackManager logging_callback_manager: LoggingCallbackManager diff --git a/litellm/_lazy_imports_registry.py b/litellm/_lazy_imports_registry.py index 93fa8b39af2..19b578c709d 100644 --- a/litellm/_lazy_imports_registry.py +++ b/litellm/_lazy_imports_registry.py @@ -282,6 +282,7 @@ TYPES_NAMES = ( "PriorityReservationSettings", "CustomLogger", "LoggingCallbackManager", + "DatadogLLMObsInitParams", # Note: LlmProviders is NOT lazy-loaded because it's imported during import time # in multiple places including openai.py (via main import) # Note: KeyManagementSettings is NOT lazy-loaded because _key_management_settings @@ -393,6 +394,7 @@ _TYPES_IMPORT_MAP = { "PriorityReservationSettings": ("litellm.types.utils", "PriorityReservationSettings"), "CustomLogger": ("litellm.integrations.custom_logger", "CustomLogger"), "LoggingCallbackManager": ("litellm.litellm_core_utils.logging_callback_manager", "LoggingCallbackManager"), + "DatadogLLMObsInitParams": ("litellm.types.integrations.datadog_llm_obs", "DatadogLLMObsInitParams"), } _LLM_PROVIDER_LOGIC_IMPORT_MAP = {