[Bug Fix] UI QA - Fix wildcard model test connection not working (#10347)

* fix setFieldsValue for wildcard

* fix async_completion_with_fallbacks

* fix ahealth_check_wildcard_models
This commit is contained in:
Ishaan Jaff
2025-04-26 17:42:06 -07:00
committed by GitHub
parent 31313dd489
commit c2480db73d
3 changed files with 19 additions and 5 deletions
+12 -3
View File
@@ -1,5 +1,6 @@
import uuid
from copy import deepcopy
from typing import Optional
import litellm
from litellm._logging import verbose_logger
@@ -31,13 +32,16 @@ async def async_completion_with_fallbacks(**kwargs):
kwargs.pop("acompletion", None) # Remove to prevent keyword conflicts
litellm_call_id = str(uuid.uuid4())
base_kwargs = {**kwargs, **nested_kwargs, "litellm_call_id": litellm_call_id}
# fields to remove
base_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] = None
for fallback in fallbacks:
try:
completion_kwargs = deepcopy(base_kwargs)
# Handle dictionary fallback configurations
if 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)
continue
raise 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."
)
+6 -1
View File
@@ -5511,7 +5511,10 @@ def speech( # noqa: PLR0915
async 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 provider
cheapest_models = pick_cheapest_chat_models_from_llm_provider(
@@ -5528,6 +5531,7 @@ async def ahealth_check_wildcard_models(
else:
fallback_models = None
model_params["model"] = cheapest_models[0]
model_params["litellm_logging_obj"] = litellm_logging_obj
model_params["fallbacks"] = fallback_models
model_params["max_tokens"] = 1
await 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_obj
@@ -23,7 +23,7 @@ const LiteLLMModelNameField: React.FC<LiteLLMModelNameFieldProps> = ({
// If "all-wildcard" is selected, clear the model_name field
if (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 update
const currentModel = form.getFieldValue('model');