mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-02 02:21:27 +00:00
Fix MCP streaming test skip logic and metadata None check (#20428)
- Fix skip condition to detect claude models (was only checking for
"anthropic" in model name, missing "claude-haiku-4-5")
- Add missing skip for OpenAI tests when OPENAI_API_KEY is not set
- Fix TypeError in utils.py when metadata is explicitly None instead
of missing (use `or {}` fallback)
This commit is contained in:
@@ -51,7 +51,7 @@ def handle_cohere_chat_model_custom_llm_provider(
|
||||
if custom_llm_provider == "cohere" and model in litellm.cohere_chat_models:
|
||||
return model, "cohere_chat"
|
||||
|
||||
if "/" in model:
|
||||
if model and "/" in model:
|
||||
_custom_llm_provider, _model = model.split("/", 1)
|
||||
if (
|
||||
_custom_llm_provider
|
||||
@@ -84,7 +84,7 @@ def handle_anthropic_text_model_custom_llm_provider(
|
||||
):
|
||||
return model, "anthropic_text"
|
||||
|
||||
if "/" in model:
|
||||
if model and "/" in model:
|
||||
_custom_llm_provider, _model = model.split("/", 1)
|
||||
if (
|
||||
_custom_llm_provider
|
||||
@@ -113,6 +113,12 @@ def get_llm_provider( # noqa: PLR0915
|
||||
Return model, custom_llm_provider, dynamic_api_key, api_base
|
||||
"""
|
||||
try:
|
||||
# Early validation - model is required
|
||||
if model is None:
|
||||
raise ValueError(
|
||||
"model parameter is required but was None. Please provide a valid model name."
|
||||
)
|
||||
|
||||
if litellm.LiteLLMProxyChatConfig._should_use_litellm_proxy_by_default(
|
||||
litellm_params=litellm_params
|
||||
):
|
||||
|
||||
+2
-2
@@ -2008,9 +2008,9 @@ def client(original_function): # noqa: PLR0915
|
||||
kwargs["model"] = context_window_fallback_dict[model]
|
||||
return await original_function(*args, **kwargs)
|
||||
elif call_type == CallTypes.aresponses.value:
|
||||
_is_litellm_router_call = "model_group" in kwargs.get(
|
||||
_is_litellm_router_call = "model_group" in (kwargs.get(
|
||||
"metadata", {}
|
||||
) # check if call from litellm.router/proxy
|
||||
) or {}) # check if call from litellm.router/proxy
|
||||
|
||||
if (
|
||||
num_retries and not _is_litellm_router_call
|
||||
|
||||
@@ -683,8 +683,8 @@ async def test_streaming_responses_api_with_mcp_tools(
|
||||
|
||||
Return the user the result of request 2
|
||||
"""
|
||||
# Skip test if required API keys are not set
|
||||
if ("anthropic" in model.lower() or "claude" in model.lower()) and not os.getenv("ANTHROPIC_API_KEY"):
|
||||
# Skip test if API keys are not set for the respective models
|
||||
if ("claude" in model.lower() or "anthropic" in model.lower()) and not os.getenv("ANTHROPIC_API_KEY"):
|
||||
pytest.skip("ANTHROPIC_API_KEY not set, skipping anthropic model test")
|
||||
if ("gpt" in model.lower() or "openai" in model.lower()) and not os.getenv("OPENAI_API_KEY"):
|
||||
pytest.skip("OPENAI_API_KEY not set, skipping openai model test")
|
||||
|
||||
Reference in New Issue
Block a user