The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
(fix) litellm utils test
Ishaan Jaffddf51d49e677
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex 09961174497..340e952af44 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -135,22 +135,22 @@ prometheus_initialize_budget_metrics: Optional[bool] = Falserequire_auth_for_metrics_endpoint: Optional[bool] = Falseargilla_batch_size: Optional[int] = Nonedatadog_use_v1: Optional[bool] = False # if you want to use v1 datadog logged payload.-gcs_pub_sub_use_v1: Optional[- bool-] = False # if you want to use v1 gcs pubsub logged payload-generic_api_use_v1: Optional[- bool-] = False # if you want to use v1 generic api logged payload+gcs_pub_sub_use_v1: Optional[bool] = (+ False # if you want to use v1 gcs pubsub logged payload+)+generic_api_use_v1: Optional[bool] = (+ False # if you want to use v1 generic api logged payload+)argilla_transformation_object: Optional[Dict[str, Any]] = None-_async_input_callback: List[- Union[str, Callable, CustomLogger]-] = [] # internal variable - async custom callbacks are routed here.-_async_success_callback: List[- Union[str, Callable, CustomLogger]-] = [] # internal variable - async custom callbacks are routed here.-_async_failure_callback: List[- Union[str, Callable, CustomLogger]-] = [] # internal variable - async custom callbacks are routed here.+_async_input_callback: List[Union[str, Callable, CustomLogger]] = (+ []+) # internal variable - async custom callbacks are routed here.+_async_success_callback: List[Union[str, Callable, CustomLogger]] = (+ []+) # internal variable - async custom callbacks are routed here.+_async_failure_callback: List[Union[str, Callable, CustomLogger]] = (+ []+) # internal variable - async custom callbacks are routed here.pre_call_rules: List[Callable] = []post_call_rules: List[Callable] = []turn_off_message_logging: Optional[bool] = False@@ -158,18 +158,18 @@ log_raw_request_response: bool = Falseredact_messages_in_exceptions: Optional[bool] = Falseredact_user_api_key_info: Optional[bool] = Falsefilter_invalid_headers: Optional[bool] = False-add_user_information_to_llm_headers: Optional[- bool-] = None # adds user_id, team_id, token hash (params from StandardLoggingMetadata) to request headers+add_user_information_to_llm_headers: Optional[bool] = (+ None # adds user_id, team_id, token hash (params from StandardLoggingMetadata) to request headers+)store_audit_logs = False # Enterprise feature, allow users to see audit logs### end of callbacks #############-email: Optional[- str-] = None # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648-token: Optional[- str-] = None # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648+email: Optional[str] = (+ None # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648+)+token: Optional[str] = (+ None # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648+)telemetry = Truemax_tokens: int = DEFAULT_MAX_TOKENS # OpenAI Defaultsdrop_params = bool(os.getenv("LITELLM_DROP_PARAMS", False))@@ -253,20 +253,24 @@ enable_loadbalancing_on_batch_endpoints: Optional[bool] = Noneenable_caching_on_provider_specific_optional_params: bool = (False # feature-flag for caching on optional params - e.g. 'top_k')-caching: bool = False # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648-caching_with_models: bool = False # # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648-cache: Optional[- Cache-] = None # cache object <- use this - https://docs.litellm.ai/docs/caching+caching: bool = (+ False # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648+)+caching_with_models: bool = (+ False # # Not used anymore, will be removed in next MAJOR release - https://github.com/BerriAI/litellm/discussions/648+)+cache: Optional[Cache] = (+ None # cache object <- use this - https://docs.litellm.ai/docs/caching+)default_in_memory_ttl: Optional[float] = Nonedefault_redis_ttl: Optional[float] = Nonedefault_redis_batch_cache_expiry: Optional[float] = Nonemodel_alias_map: Dict[str, str] = {}model_group_alias_map: Dict[str, str] = {}max_budget: float = 0.0 # set the max budget across all providers-budget_duration: Optional[- str-] = None # proxy only - resets budget after fixed duration. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d").+budget_duration: Optional[str] = (+ None # proxy only - resets budget after fixed duration. You can set duration as seconds ("30s"), minutes ("30m"), hours ("30h"), days ("30d").+)default_soft_budget: float = (DEFAULT_SOFT_BUDGET # by default all litellm proxy keys have a soft budget of 50.0)@@ -275,11 +279,15 @@ forward_traceparent_to_llm_provider: bool = False_current_cost = 0.0 # private variable, used if max budget is seterror_logs: Dict = {}-add_function_to_prompt: bool = False # if function calling not supported by api, append function call details to system prompt+add_function_to_prompt: bool = (+ False # if function calling not supported by api, append function call details to system prompt+)client_session: Optional[httpx.Client] = Noneaclient_session: Optional[httpx.AsyncClient] = Nonemodel_fallbacks: Optional[List] = None # Deprecated for 'litellm.fallbacks'-model_cost_map_url: str = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"+model_cost_map_url: str = (+ "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"+)suppress_debug_info = Falsedynamodb_table_name: Optional[str] = Nones3_callback_params: Optional[Dict] = None@@ -306,9 +314,13 @@ priority_reservation: Optional[Dict[str, float]] = None######## Networking Settings ########-use_aiohttp_transport: bool = True # Older variable, aiohttp is now the default. use disable_aiohttp_transport instead.+use_aiohttp_transport: bool = (+ True # Older variable, aiohttp is now the default. use disable_aiohttp_transport instead.+)disable_aiohttp_transport: bool = False # Set this to true to use httpx instead-force_ipv4: bool = False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.+force_ipv4: bool = (+ False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6.+)module_level_aclient = AsyncHTTPHandler(timeout=request_timeout, client_alias="module level aclient")@@ -322,13 +334,13 @@ fallbacks: Optional[List] = Nonecontext_window_fallbacks: Optional[List] = Nonecontent_policy_fallbacks: Optional[List] = Noneallowed_fails: int = 3-num_retries_per_request: Optional[- int-] = None # for the request overall (incl. fallbacks + model retries)+num_retries_per_request: Optional[int] = (+ None # for the request overall (incl. fallbacks + model retries)+)####### SECRET MANAGERS #####################-secret_manager_client: Optional[- Any-] = None # list of instantiated key management clients - e.g. azure kv, infisical, etc.+secret_manager_client: Optional[Any] = (+ None # list of instantiated key management clients - e.g. azure kv, infisical, etc.+)_google_kms_resource_name: Optional[str] = None_key_management_system: Optional[KeyManagementSystem] = None_key_management_settings: KeyManagementSettings = KeyManagementSettings()@@ -456,6 +468,7 @@ llama_models: List = []nscale_models: List = []nebius_models: List = []nebius_embedding_models: List = []+deepgram_models: List = []def is_bedrock_pricing_only_model(key: str) -> bool:@@ -627,6 +640,8 @@ def add_known_models():snowflake_models.append(key)elif value.get("litellm_provider") == "featherless_ai":featherless_ai_models.append(key)+ elif value.get("litellm_provider") == "deepgram":+ deepgram_models.append(key)add_known_models()@@ -708,6 +723,7 @@ model_list = (+ llama_models+ featherless_ai_models+ nscale_models+ + deepgram_models)model_list_set = set(model_list)@@ -771,6 +787,7 @@ models_by_provider: dict = {"meta_llama": llama_models,"nscale": nscale_models,"featherless_ai": featherless_ai_models,+ "deepgram": deepgram_models,}# mapping for those models which have larger equivalents@@ -1141,12 +1158,12 @@ from .types.llms.custom_llm import CustomLLMItemfrom .types.utils import GenericStreamingChunkcustom_provider_map: List[CustomLLMItem] = []-_custom_providers: List[- str-] = [] # internal helper util, used to track names of custom providers-disable_hf_tokenizer_download: Optional[- bool-] = None # disable huggingface tokenizer download. Defaults to openai clk100+_custom_providers: List[str] = (+ []+) # internal helper util, used to track names of custom providers+disable_hf_tokenizer_download: Optional[bool] = (+ None # disable huggingface tokenizer download. Defaults to openai clk100+)global_disable_no_log_param: bool = False### PASSTHROUGH ###