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
[Bug Fix] UI QA - Fix wildcard model test connection not working (#10347)
Ishaan Jaffc2480db73dd1
diff --git a/litellm/litellm_core_utils/fallback_utils.py b/litellm/litellm_core_utils/fallback_utils.pyindex 90c55246e5c..d5610d5fddf 100644--- a/litellm/litellm_core_utils/fallback_utils.py+++ b/litellm/litellm_core_utils/fallback_utils.py@@ -1,5 +1,6 @@import uuidfrom copy import deepcopy+from typing import Optionalimport litellmfrom litellm._logging import verbose_logger@@ -31,13 +32,16 @@ async def async_completion_with_fallbacks(**kwargs):kwargs.pop("acompletion", None) # Remove to prevent keyword conflictslitellm_call_id = str(uuid.uuid4())base_kwargs = {**kwargs, **nested_kwargs, "litellm_call_id": litellm_call_id}++ # fields to removebase_kwargs.pop("model", None) # Remove model as it will be set per fallback+ litellm_logging_obj = base_kwargs.pop("litellm_logging_obj", None)# Try each fallback model+ most_recent_exception_str: Optional[str] = Nonefor fallback in fallbacks:try:completion_kwargs = deepcopy(base_kwargs)-# Handle dictionary fallback configurationsif isinstance(fallback, dict):model = fallback.pop("model", original_model)@@ -45,7 +49,11 @@ async def async_completion_with_fallbacks(**kwargs):else:model = fallback- response = await litellm.acompletion(**completion_kwargs, model=model)+ response = await litellm.acompletion(+ **completion_kwargs,+ model=model,+ litellm_logging_obj=litellm_logging_obj,+ )if response is not None:return response@@ -54,10 +62,11 @@ async def async_completion_with_fallbacks(**kwargs):verbose_logger.exception(f"Fallback attempt failed for model {model}: {str(e)}")+ most_recent_exception_str = str(e)continueraise Exception(- "All fallback attempts failed. Enable verbose logging with `litellm.set_verbose=True` for details."+ f"{most_recent_exception_str}. All fallback attempts failed. Enable verbose logging with `litellm.set_verbose=True` for details.")diff --git a/litellm/main.py b/litellm/main.pyindex de0716fd963..c8a3ce55acc 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -5511,7 +5511,10 @@ def speech( # noqa: PLR0915async def ahealth_check_wildcard_models(- model: str, custom_llm_provider: str, model_params: dict+ model: str,+ custom_llm_provider: str,+ model_params: dict,+ litellm_logging_obj: Logging,) -> dict:# this is a wildcard model, we need to pick a random model from the providercheapest_models = pick_cheapest_chat_models_from_llm_provider(@@ -5528,6 +5531,7 @@ async def ahealth_check_wildcard_models(else:fallback_models = Nonemodel_params["model"] = cheapest_models[0]+ model_params["litellm_logging_obj"] = litellm_logging_objmodel_params["fallbacks"] = fallback_modelsmodel_params["max_tokens"] = 1await acompletion(**model_params)@@ -5594,6 +5598,7 @@ async def ahealth_check(model=model,custom_llm_provider=custom_llm_provider,model_params=model_params,+ litellm_logging_obj=litellm_logging_obj,)model_params["litellm_logging_obj"] = litellm_logging_objdiff --git a/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx b/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsxindex f5c92f8df5a..278456317bb 100644--- a/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx+++ b/ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx@@ -23,7 +23,7 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({// If "all-wildcard" is selected, clear the model_name fieldif (values.includes("all-wildcard")) {- form.setFieldsValue({ model: undefined, model_mappings: [] });+ form.setFieldsValue({ model_name: undefined, model_mappings: [] });} else {// Get current model value to check if we need to updateconst currentModel = form.getFieldValue('model');