litellm/tests/unit/test_private_usage_aliases.py
devin-ai-integration[bot] c3a23fe499
refactor: expose core private helpers under public names (#44871)
* refactor: expose core private symbols with compatibility aliases

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* types: narrow core migration diagnostics

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: preserve runtime behavior in core symbol migration

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: preserve core private usage migration behavior

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: preserve private value rebinding compatibility

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: restore optional imports and cover public helpers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: exempt router property from call coverage

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test: align recursive detector ignore names

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: mateo <mateo@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-07 00:05:27 +00:00

1052 lines
36 KiB
Python

from importlib import import_module
from types import MethodType
from typing import Final
import pytest
ALIAS_CASES: Final = (
(
"enterprise.enterprise_hooks.banned_keywords",
"",
"_ENTERPRISE_BannedKeywords",
"ENTERPRISE_BannedKeywords",
False,
),
(
"enterprise.enterprise_hooks.blocked_user_list",
"",
"_ENTERPRISE_BlockedUserList",
"ENTERPRISE_BlockedUserList",
False,
),
(
"enterprise.enterprise_hooks.google_text_moderation",
"",
"_ENTERPRISE_GoogleTextModeration",
"ENTERPRISE_GoogleTextModeration",
False,
),
(
"enterprise.enterprise_hooks.openai_moderation",
"",
"_ENTERPRISE_OpenAI_Moderation",
"ENTERPRISE_OpenAI_Moderation",
False,
),
(
"enterprise.litellm_enterprise.proxy.hooks.managed_files",
"",
"_PROXY_LiteLLMManagedFiles",
"PROXY_LiteLLMManagedFiles",
False,
),
(
"enterprise.litellm_enterprise.proxy.hooks.managed_vector_stores",
"",
"_PROXY_LiteLLMManagedVectorStores",
"PROXY_LiteLLMManagedVectorStores",
False,
),
("litellm", "", "_calculate_retry_after", "calculate_retry_after", False),
("litellm", "", "_turn_on_debug", "turn_on_debug", False),
("litellm", "", "_turn_on_json", "turn_on_json", False),
("litellm._lazy_imports", "", "_get_default_encoding", "get_default_encoding", False),
("litellm._lazy_imports", "", "_get_lazy_import_registry", "get_lazy_import_registry", False),
("litellm._lazy_imports", "", "_get_messages_reach_token_count", "get_messages_reach_token_count", False),
("litellm._lazy_imports", "", "_get_token_counter_new", "get_token_counter_new", False),
("litellm._logging", "", "_is_debugging_on", "is_debugging_on", False),
("litellm._logging", "", "_redact_string", "redact_string", False),
("litellm._logging", "", "_turn_on_debug", "turn_on_debug", False),
("litellm._logging", "", "_turn_on_json", "turn_on_json", False),
("litellm._redis", "", "_generate_gcp_iam_access_token", "generate_gcp_iam_access_token", False),
(
"litellm._redis_credential_provider",
"",
"_generate_gcp_iam_access_token",
"generate_gcp_iam_access_token",
False,
),
("litellm", "", "_should_retry", "should_retry", False),
("litellm.batches.batch_utils", "", "_count_entry_tokens", "count_entry_tokens", False),
("litellm.batches.batch_utils", "", "_estimate_batch_entry_tokens", "estimate_batch_entry_tokens", False),
("litellm.batches.batch_utils", "", "_extract_file_access_credentials", "extract_file_access_credentials", False),
("litellm.batches.batch_utils", "", "_get_file_content_as_dictionary", "get_file_content_as_dictionary", False),
("litellm.batches.batch_utils", "", "_handle_completed_batch", "handle_completed_batch", False),
("litellm.batches.batch_utils", "", "_iter_batch_input_lines", "iter_batch_input_lines", False),
("litellm.caching.caching", "Cache", "_get_cache_logic", "get_cache_logic", False),
(
"litellm.caching.caching",
"Cache",
"_get_preset_cache_key_from_kwargs",
"get_preset_cache_key_from_kwargs",
False,
),
("litellm.caching.caching", "Cache", "_supports_async", "supports_async", False),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_add_streaming_response_to_cache",
"add_streaming_response_to_cache",
False,
),
("litellm.caching.caching_handler", "LLMCachingHandler", "_async_get_cache", "async_get_cache", False),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_combine_cached_embedding_response_with_api_result",
"combine_cached_embedding_response_with_api_result",
False,
),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_should_store_result_in_cache",
"should_store_result_in_cache",
False,
),
(
"litellm.caching.caching_handler",
"LLMCachingHandler",
"_sync_add_streaming_response_to_cache",
"sync_add_streaming_response_to_cache",
False,
),
("litellm.caching.caching_handler", "LLMCachingHandler", "_sync_get_cache", "sync_get_cache", False),
(
"litellm.completion_extras.litellm_responses_transformation.transformation",
"LiteLLMResponsesTransformationHandler",
"_map_reasoning_effort",
"map_reasoning_effort",
False,
),
("litellm.cost_calculator", "", "_infer_call_type", "infer_call_type", False),
("litellm.cost_calculator", "", "_select_model_name_for_cost_calc", "select_model_name_for_cost_calc", False),
(
"litellm.integrations.SlackAlerting.utils",
"",
"_add_langfuse_trace_id_to_alert",
"add_langfuse_trace_id_to_alert",
False,
),
(
"litellm.integrations.arize.arize_phoenix_prompt_manager",
"ArizePhoenixTemplateManager",
"_load_prompt_from_arize",
"load_prompt_from_arize",
False,
),
(
"litellm.integrations.bitbucket.bitbucket_prompt_manager",
"BitBucketTemplateManager",
"_load_prompt_from_bitbucket",
"load_prompt_from_bitbucket",
False,
),
(
"litellm.integrations.dotprompt",
"",
"_get_prompt_data_from_dotprompt_content",
"get_prompt_data_from_dotprompt_content",
False,
),
(
"litellm.integrations.dotprompt.prompt_manager",
"PromptManager",
"_parse_frontmatter",
"parse_frontmatter",
False,
),
("litellm.integrations.dynamodb", "DyanmoDBLogger", "_async_log_event", "async_log_event", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_build_filename", "build_filename", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_count_unique", "count_unique", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_database", "database", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_destination", "destination", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_serializer", "serializer", True),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_sum_column", "sum_column", False),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_transformer", "transformer", True),
(
"litellm.integrations.gitlab.gitlab_prompt_manager",
"GitLabTemplateManager",
"_id_to_repo_path",
"id_to_repo_path",
False,
),
(
"litellm.integrations.gitlab.gitlab_prompt_manager",
"GitLabTemplateManager",
"_load_prompt_from_gitlab",
"load_prompt_from_gitlab",
False,
),
(
"litellm.integrations.opentelemetry",
"",
"_build_metric_attribute_filter",
"build_metric_attribute_filter",
False,
),
(
"litellm.integrations.opentelemetry",
"",
"_resolve_metric_attribute_filter",
"resolve_metric_attribute_filter",
False,
),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_custom_by_sanitized_key",
"custom_by_sanitized_key",
True,
),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_sanitized_enum",
"sanitized_enum",
True,
),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_tag_labels", "tag_labels", True),
(
"litellm.integrations.prometheus_helpers",
"",
"_get_cached_end_user_id_for_cost_tracking",
"get_cached_end_user_id_for_cost_tracking",
False,
),
(
"litellm.integrations.weave.weave_otel",
"",
"_get_weave_authorization_header",
"get_weave_authorization_header",
False,
),
(
"litellm.litellm_core_utils.core_helpers",
"",
"_get_parent_otel_span_from_kwargs",
"get_parent_otel_span_from_kwargs",
False,
),
("litellm.litellm_core_utils.dd_tracing", "", "_should_use_dd_profiler", "should_use_dd_profiler", False),
(
"litellm.litellm_core_utils.exception_mapping_utils",
"",
"_add_key_name_and_team_to_alert",
"add_key_name_and_team_to_alert",
False,
),
(
"litellm.litellm_core_utils.get_litellm_params",
"",
"_get_base_model_from_litellm_call_metadata",
"get_base_model_from_litellm_call_metadata",
False,
),
(
"litellm.litellm_core_utils.get_llm_provider_logic",
"",
"_is_non_openai_azure_model",
"is_non_openai_azure_model",
False,
),
(
"litellm.litellm_core_utils.get_model_cost_map",
"GetModelCostMap",
"_get_backup_model_count",
"get_backup_model_count",
False,
),
(
"litellm.litellm_core_utils.health_check_helpers",
"HealthCheckHelpers",
"_update_model_params_with_health_check_tracking_information",
"update_model_params_with_health_check_tracking_information",
False,
),
(
"litellm.litellm_core_utils.health_check_utils",
"",
"_create_health_check_response",
"create_health_check_response",
False,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_defer_async_logging", "defer_async_logging", True),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_enqueue_deferred_logging",
"enqueue_deferred_logging",
True,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_get_trace_id", "get_trace_id", False),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_is_sync_litellm_request",
"is_sync_litellm_request",
False,
),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_llm_caching_handler", "llm_caching_handler", True),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_on_detached_stream_failure",
"on_detached_stream_failure",
True,
),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_response_cost_calculator",
"response_cost_calculator",
False,
),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_update_completion_start_time",
"update_completion_start_time",
False,
),
(
"litellm.litellm_core_utils.litellm_logging",
"StandardLoggingPayloadSetup",
"_get_request_tags",
"get_request_tags",
False,
),
("litellm.litellm_core_utils.litellm_logging", "", "_get_masked_values", "get_masked_values", False),
(
"litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking",
"StandardBuiltInToolCostTracking",
"_get_file_search_tool_call",
"get_file_search_tool_call",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.tool_call_cost_tracking",
"StandardBuiltInToolCostTracking",
"_get_web_search_options",
"get_web_search_options",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"CostCalculatorUtils",
"_call_type_has_image_response",
"call_type_has_image_response",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_generic_cost_per_character",
"generic_cost_per_character",
False,
),
("litellm.litellm_core_utils.llm_cost_calc.utils", "", "_get_cost_per_unit", "get_cost_per_unit", False),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_get_regional_uplift_multiplier",
"get_regional_uplift_multiplier",
False,
),
(
"litellm.litellm_core_utils.llm_cost_calc.utils",
"",
"_get_service_tier_cost_key",
"get_service_tier_cost_key",
False,
),
("litellm.litellm_core_utils.llm_cost_calc.utils", "", "_is_above_128k", "is_above_128k", False),
(
"litellm.litellm_core_utils.llm_request_utils",
"",
"_ensure_extra_body_is_safe",
"ensure_extra_body_is_safe",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_handle_invalid_parallel_tool_calls",
"handle_invalid_parallel_tool_calls",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_safe_convert_created_field",
"safe_convert_created_field",
False,
),
(
"litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response",
"",
"_should_convert_tool_call_to_json_mode",
"should_convert_tool_call_to_json_mode",
False,
),
(
"litellm.litellm_core_utils.logging_callback_manager",
"LoggingCallbackManager",
"_add_custom_callback_generic_api_str",
"add_custom_callback_generic_api_str",
False,
),
(
"litellm.litellm_core_utils.logging_callback_manager",
"LoggingCallbackManager",
"_get_all_callbacks",
"get_all_callbacks",
False,
),
(
"litellm.litellm_core_utils.logging_utils",
"",
"_assemble_complete_response_from_streaming_chunks",
"assemble_complete_response_from_streaming_chunks",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_get_all_llm_api_params",
"get_all_llm_api_params",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_get_relevant_args_to_use_for_logging",
"get_relevant_args_to_use_for_logging",
False,
),
(
"litellm.litellm_core_utils.model_param_helper",
"ModelParamHelper",
"_relevant_logging_args",
"relevant_logging_args",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_audio_or_image_in_message_content",
"audio_or_image_in_message_content",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_extract_reasoning_content",
"extract_reasoning_content",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_get_image_mime_type_from_url",
"get_image_mime_type_from_url",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.common_utils",
"",
"_parse_content_for_reasoning",
"parse_content_for_reasoning",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"BedrockConverseMessagesProcessor",
"_process_file_message",
"process_file_message",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"BedrockImageProcessor",
"_validate_format",
"validate_format",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"",
"_encode_tool_call_id_with_signature",
"encode_tool_call_id_with_signature",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.factory",
"",
"_get_thought_signature_from_tool",
"get_thought_signature_from_tool",
False,
),
("litellm.litellm_core_utils.prompt_templates.factory", "", "_parse_mime_type", "parse_mime_type", False),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_aget_chat_template_file",
"aget_chat_template_file",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_aget_tokenizer_config",
"aget_tokenizer_config",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_extract_token_value",
"extract_token_value",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_get_chat_template_file",
"get_chat_template_file",
False,
),
(
"litellm.litellm_core_utils.prompt_templates.huggingface_template_handler",
"",
"_get_tokenizer_config",
"get_tokenizer_config",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_detect_beta_header",
"detect_beta_header",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_maybe_inject_guardrail_auto_response_disable",
"maybe_inject_guardrail_auto_response_disable",
False,
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_session_created_sent_to_client",
"session_created_sent_to_client",
True,
),
("litellm.litellm_core_utils.secret_redaction", "", "_python_redact_string", "python_redact_string", False),
(
"litellm.litellm_core_utils.secret_redaction",
"",
"_python_redact_structured_value",
"python_redact_structured_value",
False,
),
("litellm.litellm_core_utils.sensitive_data_masker", "SensitiveDataMasker", "_mask_value", "mask_value", False),
(
"litellm.litellm_core_utils.streaming_handler",
"CustomStreamWrapper",
"_strip_sse_data_from_chunk",
"strip_sse_data_from_chunk",
False,
),
(
"litellm.proxy.enterprise.litellm_enterprise.proxy.utils",
"",
"_should_block_robots",
"should_block_robots",
False,
),
("litellm.realtime_api.main", "", "_realtime_health_check", "realtime_health_check", False),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_tool_call_id_from_responses_item",
"tool_call_id_from_responses_item",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_chat_completion_annotations_to_response_output_annotations",
"transform_chat_completion_annotations_to_response_output_annotations",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_chat_completion_usage_to_responses_usage",
"transform_chat_completion_usage_to_responses_usage",
False,
),
(
"litellm.responses.litellm_completion_transformation.transformation",
"LiteLLMCompletionResponsesConfig",
"_transform_tool_choice_for_responses_api_response",
"transform_tool_choice_for_responses_api_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_add_mcp_output_elements_to_response",
"add_mcp_output_elements_to_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_follow_up_input",
"create_follow_up_input",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_follow_up_messages_for_chat",
"create_follow_up_messages_for_chat",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_create_tool_execution_events",
"create_tool_execution_events",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_execute_tool_calls",
"execute_tool_calls",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_call_details",
"extract_tool_call_details",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_calls_from_chat_response",
"extract_tool_calls_from_chat_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_extract_tool_calls_from_response",
"extract_tool_calls_from_response",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_get_parent_request_tags",
"get_parent_request_tags",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_is_persistence_disabled",
"is_persistence_disabled",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_make_follow_up_call",
"make_follow_up_call",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_prepare_follow_up_call_params",
"prepare_follow_up_call_params",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_prepare_initial_call_params",
"prepare_initial_call_params",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_process_mcp_tools_to_openai_format",
"process_mcp_tools_to_openai_format",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_process_mcp_tools_without_openai_transform",
"process_mcp_tools_without_openai_transform",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_should_auto_execute_tools",
"should_auto_execute_tools",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_should_use_litellm_mcp_gateway",
"should_use_litellm_mcp_gateway",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_split_mcp_tools",
"split_mcp_tools",
False,
),
(
"litellm.responses.mcp.litellm_proxy_mcp_handler",
"LiteLLM_Proxy_MCP_Handler",
"_transform_mcp_tools_to_openai",
"transform_mcp_tools_to_openai",
False,
),
("litellm.responses.streaming_iterator", "", "_get_openai_response_types", "get_openai_response_types", False),
("litellm.responses.utils", "ResponseAPILoggingUtils", "_is_response_api_usage", "is_response_api_usage", False),
(
"litellm.responses.utils",
"ResponseAPILoggingUtils",
"_transform_response_api_usage_to_chat_usage",
"transform_response_api_usage_to_chat_usage",
False,
),
("litellm.responses.utils", "ResponsesAPIRequestUtils", "_build_container_id", "build_container_id", False),
("litellm.responses.utils", "ResponsesAPIRequestUtils", "_decode_container_id", "decode_container_id", False),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_decode_encrypted_item_id",
"decode_encrypted_item_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_decode_responses_api_response_id",
"decode_responses_api_response_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_encode_container_id_on_output_item",
"encode_container_id_on_output_item",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_encode_container_ids_in_annotations",
"encode_container_ids_in_annotations",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_restore_encrypted_content_item_ids_in_input",
"restore_encrypted_content_item_ids_in_input",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_unwrap_encrypted_content_with_model_id",
"unwrap_encrypted_content_with_model_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_update_responses_api_response_id_with_model_id",
"update_responses_api_response_id_with_model_id",
False,
),
(
"litellm.responses.utils",
"ResponsesAPIRequestUtils",
"_wrap_encrypted_content_with_model_id",
"wrap_encrypted_content_with_model_id",
False,
),
("litellm.router", "Router", "_are_all_deployments_blocked", "are_all_deployments_blocked", False),
("litellm.router", "Router", "_deployment_usable_by_team", "deployment_usable_by_team", False),
("litellm.router", "Router", "_get_all_deployments", "get_all_deployments", False),
("litellm.router", "Router", "_get_model_from_alias", "get_model_from_alias", False),
(
"litellm.router",
"Router",
"_get_router_deployment_budget_limiter",
"get_router_deployment_budget_limiter",
False,
),
("litellm.router", "Router", "_is_deployment_blocked", "is_deployment_blocked", False),
(
"litellm.router",
"Router",
"_is_model_access_group_for_wildcard_route",
"is_model_access_group_for_wildcard_route",
False,
),
("litellm.router", "Router", "_replay_model_cost_registrations", "replay_model_cost_registrations", False),
("litellm.router", "Router", "_routing_groups", "routing_groups", True),
("litellm.router", "Router", "_update_redis_cache", "update_redis_cache", False),
(
"litellm.router_strategy.adaptive_router.adaptive_router",
"AdaptiveRouter",
"_state_loaded",
"state_loaded",
True,
),
(
"litellm.router_strategy.tag_based_routing",
"",
"_get_tags_from_request_kwargs",
"get_tags_from_request_kwargs",
False,
),
("litellm.router_utils.add_retry_fallback_headers", "HiddenParamsAsyncIteratorWrapper", "_inner", "inner", True),
("litellm.router_utils.add_retry_fallback_headers", "", "_HiddenParamsHost", "HiddenParamsHost", False),
(
"litellm.router_utils.batch_utils",
"",
"_get_router_metadata_variable_name",
"get_router_metadata_variable_name",
False,
),
("litellm.router_utils.common_utils", "", "_is_proxy_admin_request", "is_proxy_admin_request", False),
(
"litellm.router_utils.cooldown_callbacks",
"",
"_get_prometheus_logger_from_callbacks",
"get_prometheus_logger_from_callbacks",
False,
),
(
"litellm.router_utils.cooldown_handlers",
"",
"_async_get_cooldown_deployments",
"async_get_cooldown_deployments",
False,
),
(
"litellm.router_utils.cooldown_handlers",
"",
"_async_get_cooldown_deployments_with_debug_info",
"async_get_cooldown_deployments_with_debug_info",
False,
),
("litellm.router_utils.cooldown_handlers", "", "_get_cooldown_deployments", "get_cooldown_deployments", False),
("litellm.router_utils.cooldown_handlers", "", "_set_cooldown_deployments", "set_cooldown_deployments", False),
(
"litellm.router_utils.fallback_event_handlers",
"",
"_check_non_standard_fallback_format",
"check_non_standard_fallback_format",
False,
),
(
"litellm.router_utils.pattern_match_deployments",
"PatternMatchRouter",
"_pattern_to_regex",
"pattern_to_regex",
False,
),
("litellm.types.agents", "", "_normalize_a2a_jsonrpc_response", "normalize_a2a_jsonrpc_response", False),
("litellm.types.completion", "", "_CompletionDispatchContext", "CompletionDispatchContext", False),
(
"litellm.types.integrations.prometheus",
"",
"_sanitize_prometheus_label_name",
"sanitize_prometheus_label_name",
False,
),
(
"litellm.types.integrations.prometheus",
"",
"_sanitize_prometheus_label_value",
"sanitize_prometheus_label_value",
False,
),
("litellm.types.utils", "", "_generate_id", "generate_id", False),
("litellm.utils", "ProviderConfigManager", "_get_bedrock_mantle_config", "get_bedrock_mantle_config", False),
(
"litellm.utils",
"",
"_add_custom_logger_callback_to_specific_event",
"add_custom_logger_callback_to_specific_event",
False,
),
("litellm.utils", "", "_add_path_to_api_base", "add_path_to_api_base", False),
("litellm.utils", "", "_apply_openai_param_overrides", "apply_openai_param_overrides", False),
("litellm.utils", "", "_cached_get_model_info_helper", "cached_get_model_info_helper", False),
("litellm.utils", "", "_calculate_retry_after", "calculate_retry_after", False),
("litellm.utils", "", "_count_characters", "count_characters", False),
("litellm.utils", "", "_get_base_model_from_metadata", "get_base_model_from_metadata", False),
("litellm.utils", "", "_get_bundled_model_cost_map", "get_bundled_model_cost_map", False),
("litellm.utils", "", "_get_deployment_order", "get_deployment_order", False),
("litellm.utils", "", "_get_model_cost_key", "get_model_cost_key", False),
("litellm.utils", "", "_get_model_info_helper", "get_model_info_helper", False),
("litellm.utils", "", "_get_potential_model_names", "get_potential_model_names", False),
("litellm.utils", "", "_remove_additional_properties", "remove_additional_properties", False),
("litellm.utils", "", "_remove_json_schema_refs", "remove_json_schema_refs", False),
("litellm.utils", "", "_remove_strict_from_schema", "remove_strict_from_schema", False),
("litellm.utils", "", "_select_tokenizer", "select_tokenizer", False),
("litellm.utils", "", "_should_retry", "should_retry", False),
("litellm.utils", "", "_supports_factory", "supports_factory", False),
("litellm.utils", "", "_update_dictionary", "update_dictionary", False),
(
"litellm.vector_stores.vector_store_registry",
"VectorStoreIndexRegistry",
"_get_vector_store_indexes_from_db",
"get_vector_store_indexes_from_db",
False,
),
(
"litellm.vector_stores.vector_store_registry",
"VectorStoreRegistry",
"_get_vector_stores_from_db",
"get_vector_stores_from_db",
False,
),
)
PROPERTY_CASES: Final = (
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_database", "database"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_destination", "destination"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_serializer", "serializer"),
("litellm.integrations.focus.export_engine", "FocusExportEngine", "_transformer", "transformer"),
(
"litellm.integrations.prometheus_helpers",
"PrometheusLabelFactoryContext",
"_custom_by_sanitized_key",
"custom_by_sanitized_key",
),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_sanitized_enum", "sanitized_enum"),
("litellm.integrations.prometheus_helpers", "PrometheusLabelFactoryContext", "_tag_labels", "tag_labels"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_defer_async_logging", "defer_async_logging"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_enqueue_deferred_logging", "enqueue_deferred_logging"),
("litellm.litellm_core_utils.litellm_logging", "Logging", "_llm_caching_handler", "llm_caching_handler"),
(
"litellm.litellm_core_utils.litellm_logging",
"Logging",
"_on_detached_stream_failure",
"on_detached_stream_failure",
),
(
"litellm.litellm_core_utils.realtime_streaming",
"RealTimeStreaming",
"_session_created_sent_to_client",
"session_created_sent_to_client",
),
("litellm.router", "Router", "_routing_groups", "routing_groups"),
("litellm.router_strategy.adaptive_router.adaptive_router", "AdaptiveRouter", "_state_loaded", "state_loaded"),
("litellm.router_utils.add_retry_fallback_headers", "HiddenParamsAsyncIteratorWrapper", "_inner", "inner"),
)
CLASS_PROPERTY_CASES: Final = ()
def _get_owner(module_path: str, owner_name: str) -> object:
module: Final = import_module(module_path or "litellm")
return module if not owner_name else getattr(module, owner_name)
def _get_instance(owner: object, public_name: str) -> object:
if not isinstance(owner, type):
raise TypeError(f"expected a class owner, got {type(owner).__name__}")
instance: Final = object.__new__(owner)
setattr(instance, public_name, object())
return instance
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name", "use_instance"),
ALIAS_CASES,
)
def test_public_aliases(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
use_instance: bool,
) -> None:
resolved_owner: Final = _get_owner(module_path, owner_name)
alias_owner: Final = _get_instance(resolved_owner, new_name) if use_instance else resolved_owner
old_value, new_value = getattr(alias_owner, old_name), getattr(alias_owner, new_name)
if isinstance(old_value, MethodType) and isinstance(new_value, MethodType):
assert old_value.__func__ is new_value.__func__
else:
assert old_value is new_value
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name"),
PROPERTY_CASES,
)
def test_protected_data_properties_round_trip(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
) -> None:
owner: Final = _get_owner(module_path, owner_name)
if not isinstance(owner, type):
raise TypeError(f"expected a class owner, got {type(owner).__name__}")
instance: Final = object.__new__(owner)
first_value: Final = object()
second_value: Final = object()
setattr(instance, new_name, first_value)
assert getattr(instance, old_name) is first_value
setattr(instance, old_name, second_value)
assert getattr(instance, new_name) is second_value
@pytest.mark.parametrize(
("module_path", "owner_name", "old_name", "new_name"),
CLASS_PROPERTY_CASES,
)
def test_class_level_property_alias_round_trip(
module_path: str,
owner_name: str,
old_name: str,
new_name: str,
) -> None:
owner: Final = _get_owner(module_path, owner_name)
first_value: Final = object()
second_value: Final = object()
original_class_value: Final = getattr(owner, new_name)
try:
setattr(owner, old_name, first_value)
assert getattr(owner, new_name) is first_value
setattr(owner, new_name, second_value)
assert getattr(owner, old_name) is second_value
finally:
setattr(owner, new_name, original_class_value)