mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(ci): fix tests failing when LITELLM_LOCAL_MODEL_COST_MAP is set by parallel tests
- Mock get_max_tokens in test_get_config_with_model_uses_dynamic_max_tokens (claude-3-5-sonnet-20241022 not in local cost map) - Replace gemini-1.5-pro with gemini-3-flash-preview in context_caching_ttl tests (gemini-1.5-pro removed from local cost map, causing system_instruction extraction to fail when LITELLM_LOCAL_MODEL_COST_MAP=True is leaked from parallel test workers) Co-authored-by: yuneng-jiang <yuneng-jiang@users.noreply.github.com>
This commit is contained in:
parent
4a42aca961
commit
10fa3d28f6
3 changed files with 23 additions and 16 deletions
|
|
@ -1882,13 +1882,20 @@ def test_get_config_with_model_uses_dynamic_max_tokens():
|
|||
|
||||
Fixes: https://github.com/BerriAI/litellm/issues/8835
|
||||
"""
|
||||
from unittest.mock import patch
|
||||
|
||||
# Claude 3 model should get 4096
|
||||
config_claude3 = AnthropicConfig.get_config(model="claude-3-sonnet-20240229")
|
||||
assert config_claude3["max_tokens"] == 4096
|
||||
|
||||
# Claude 3.5 model should get 8192
|
||||
config_claude35 = AnthropicConfig.get_config(model="claude-3-5-sonnet-20241022")
|
||||
assert config_claude35["max_tokens"] == 8192
|
||||
# Claude 3.5 model should get 8192 (mock get_max_tokens since the model
|
||||
# may not be in the local cost map when LITELLM_LOCAL_MODEL_COST_MAP is set)
|
||||
with patch(
|
||||
"litellm.llms.anthropic.chat.transformation.get_max_tokens",
|
||||
return_value=8192,
|
||||
):
|
||||
config_claude35 = AnthropicConfig.get_config(model="claude-3-5-sonnet-20241022")
|
||||
assert config_claude35["max_tokens"] == 8192
|
||||
|
||||
# Claude 3.7 model should get 64000 (64K default, 128K requires beta header)
|
||||
config_claude37 = AnthropicConfig.get_config(model="claude-3-7-sonnet-20250219")
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class TestTransformationWithTTL:
|
|||
vertex_project="test_project"
|
||||
|
||||
result = transform_openai_messages_to_gemini_context_caching(
|
||||
model="gemini-1.5-pro",
|
||||
model="gemini-3-flash-preview",
|
||||
messages=messages,
|
||||
cache_key="test-cache-key",
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
|
|
@ -223,9 +223,9 @@ class TestTransformationWithTTL:
|
|||
assert result["ttl"] == "3600s"
|
||||
|
||||
if custom_llm_provider == "gemini":
|
||||
assert result["model"] == "models/gemini-1.5-pro"
|
||||
assert result["model"] == "models/gemini-3-flash-preview"
|
||||
else:
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-1.5-pro"
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-3-flash-preview"
|
||||
|
||||
|
||||
assert result["displayName"] == "test-cache-key"
|
||||
|
|
@ -250,7 +250,7 @@ class TestTransformationWithTTL:
|
|||
vertex_project="test_project"
|
||||
|
||||
result = transform_openai_messages_to_gemini_context_caching(
|
||||
model="gemini-1.5-pro",
|
||||
model="gemini-3-flash-preview",
|
||||
messages=messages,
|
||||
cache_key="test-cache-key",
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
|
|
@ -261,9 +261,9 @@ class TestTransformationWithTTL:
|
|||
assert "ttl" not in result
|
||||
|
||||
if custom_llm_provider == "gemini":
|
||||
assert result["model"] == "models/gemini-1.5-pro"
|
||||
assert result["model"] == "models/gemini-3-flash-preview"
|
||||
else:
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-1.5-pro"
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-3-flash-preview"
|
||||
|
||||
assert result["displayName"] == "test-cache-key"
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ class TestTransformationWithTTL:
|
|||
vertex_project="test_project"
|
||||
|
||||
result = transform_openai_messages_to_gemini_context_caching(
|
||||
model="gemini-1.5-pro",
|
||||
model="gemini-3-flash-preview",
|
||||
messages=messages,
|
||||
cache_key="test-cache-key",
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
|
|
@ -297,9 +297,9 @@ class TestTransformationWithTTL:
|
|||
assert "ttl" not in result
|
||||
|
||||
if custom_llm_provider == "gemini":
|
||||
assert result["model"] == "models/gemini-1.5-pro"
|
||||
assert result["model"] == "models/gemini-3-flash-preview"
|
||||
else:
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-1.5-pro"
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-3-flash-preview"
|
||||
|
||||
assert result["displayName"] == "test-cache-key"
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ class TestTransformationWithTTL:
|
|||
vertex_project="test_project"
|
||||
|
||||
result = transform_openai_messages_to_gemini_context_caching(
|
||||
model="gemini-1.5-pro",
|
||||
model="gemini-3-flash-preview",
|
||||
messages=messages,
|
||||
cache_key="test-cache-key",
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
|
|
@ -345,9 +345,9 @@ class TestTransformationWithTTL:
|
|||
assert "system_instruction" in result
|
||||
|
||||
if custom_llm_provider == "gemini":
|
||||
assert result["model"] == "models/gemini-1.5-pro"
|
||||
assert result["model"] == "models/gemini-3-flash-preview"
|
||||
else:
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-1.5-pro"
|
||||
assert result["model"] == f"projects/{vertex_project}/locations/{vertex_location}/publishers/google/models/gemini-3-flash-preview"
|
||||
|
||||
assert result["displayName"] == "test-cache-key"
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ def test_supports_function_calling_github_openai_alias():
|
|||
def test_supports_function_calling_github_anthropic_alias():
|
||||
assert (
|
||||
litellm.utils.supports_function_calling(
|
||||
model="github/claude-3-5-sonnet-latest"
|
||||
model="github/claude-3-7-sonnet-20250219"
|
||||
)
|
||||
is True
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue