This commit is contained in:
Otis Cui 2026-08-27 17:44:24 -05:00 • committed by GitHub
commit 3cb363d4cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -218,7 +218,7 @@ def get_llm_provider(
dynamic_api_key=dynamic_api_key,
litellm_params=litellm_params,
)
elif model.split("/", 1)[0] in litellm.provider_list:
elif model.split("/", 1)[0] in litellm.provider_list and len(model.split("/")) > 1:
custom_llm_provider = model.split("/", 1)[0]
model = model.split("/", 1)[1]
if api_base is not None and not isinstance(api_base, str):

View file

@ -0,0 +1,12 @@
import pytest
import litellm
@pytest.mark.parametrize("model", ["mistral", "openai", "anthropic", "groq", "deepseek"])
def test_get_llm_provider_bare_provider_name_raises_helpful_error(model):
with pytest.raises(litellm.BadRequestError) as exc_info:
litellm.get_llm_provider(model=model)
message = str(exc_info.value)
assert "LLM Provider NOT provided" in message
assert "list index out of range" not in message