|
74 | 74 | DEFAULT_SOFT_BUDGET, |
75 | 75 | DEFAULT_ALLOWED_FAILS, |
76 | 76 | ) |
77 | | -from litellm.types.secret_managers.main import ( |
78 | | - KeyManagementSystem, |
79 | | - KeyManagementSettings, |
80 | | -) |
81 | 77 | from litellm.types.utils import LlmProviders, PriorityReservationSettings |
82 | 78 | if TYPE_CHECKING: |
83 | 79 | from litellm.integrations.custom_logger import CustomLogger |
84 | 80 | from litellm.types.llms.bedrock import COHERE_EMBEDDING_INPUT_TYPES |
85 | 81 | from litellm.types.guardrails import GuardrailItem |
86 | 82 | from litellm.types.utils import CredentialItem, BudgetConfig, PriorityReservationDict, StandardKeyGenerationConfig, LlmProviders, PriorityReservationSettings |
87 | 83 | from litellm.types.proxy.management_endpoints.ui_sso import DefaultTeamSSOParams, LiteLLM_UpperboundKeyGenerateParams |
| 84 | + from litellm.types.secret_managers.main import KeyManagementSystem, KeyManagementSettings |
88 | 85 | import httpx |
89 | 86 | import dotenv |
90 | 87 | from litellm.llms.custom_httpx.async_client_cleanup import register_async_client_cleanup |
@@ -440,8 +437,11 @@ def __getattr__(self, name: str) -> Any: |
440 | 437 | None # list of instantiated key management clients - e.g. azure kv, infisical, etc. |
441 | 438 | ) |
442 | 439 | _google_kms_resource_name: Optional[str] = None |
443 | | -_key_management_system: Optional[KeyManagementSystem] = None |
444 | | -_key_management_settings: KeyManagementSettings = KeyManagementSettings() |
| 440 | +_key_management_system: Optional["KeyManagementSystem"] = None |
| 441 | +# _key_management_settings is lazy-loaded but needs to be initialized early |
| 442 | +# Import KeyManagementSettings here to avoid circular import issues |
| 443 | +from litellm.types.secret_managers.main import KeyManagementSettings |
| 444 | +_key_management_settings: "KeyManagementSettings" = KeyManagementSettings() |
445 | 445 | #### PII MASKING #### |
446 | 446 | output_parse_pii: bool = False |
447 | 447 | ############################################# |
@@ -1818,6 +1818,21 @@ def _lazy_import_ui_sso(name: str) -> Any: |
1818 | 1818 | raise AttributeError(f"UI SSO lazy import: unknown attribute {name!r}") |
1819 | 1819 |
|
1820 | 1820 |
|
| 1821 | +def _lazy_import_secret_managers(name: str) -> Any: |
| 1822 | + """Lazy import for types.secret_managers.main module - imports only the requested item by name.""" |
| 1823 | + if name == "KeyManagementSystem": |
| 1824 | + from litellm.types.secret_managers.main import KeyManagementSystem as _KeyManagementSystem |
| 1825 | + globals()["KeyManagementSystem"] = _KeyManagementSystem |
| 1826 | + return _KeyManagementSystem |
| 1827 | + |
| 1828 | + if name == "KeyManagementSettings": |
| 1829 | + from litellm.types.secret_managers.main import KeyManagementSettings as _KeyManagementSettings |
| 1830 | + globals()["KeyManagementSettings"] = _KeyManagementSettings |
| 1831 | + return _KeyManagementSettings |
| 1832 | + |
| 1833 | + raise AttributeError(f"Secret managers lazy import: unknown attribute {name!r}") |
| 1834 | + |
| 1835 | + |
1821 | 1836 | def __getattr__(name: str) -> Any: |
1822 | 1837 | """Lazy import for cost_calculator, litellm_logging, and utils functions.""" |
1823 | 1838 | if name in {"completion_cost", "response_cost_calculator", "cost_per_token"}: |
@@ -1870,6 +1885,9 @@ def __getattr__(name: str) -> Any: |
1870 | 1885 | if name in {"DefaultTeamSSOParams", "LiteLLM_UpperboundKeyGenerateParams"}: |
1871 | 1886 | return _lazy_import_ui_sso(name) |
1872 | 1887 |
|
| 1888 | + if name in {"KeyManagementSystem", "KeyManagementSettings"}: |
| 1889 | + return _lazy_import_secret_managers(name) |
| 1890 | + |
1873 | 1891 | if name == "provider_list": |
1874 | 1892 | provider_list_val = list(LlmProviders) |
1875 | 1893 | globals()["provider_list"] = provider_list_val |
|
0 commit comments