mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-15 14:21:58 +00:00
fix(tests): stabilize 3 failing CI tests
1. Add missing __init__.py files in tests/test_litellm/llms/gemini/ and subdirectories (realtime/, image_edit/) to fix ModuleNotFoundError with pytest-xdist parallel workers. 2. Update test_transform_request_uses_dynamic_max_tokens to use claude-3-7-sonnet-20250219 (max_output_tokens=64000) since claude-3-5-sonnet-20241022 was removed from model_prices JSON during deprecated model cleanup. The test assertion was outdated. 3. Update context caching TTL tests to use gemini-2.5-pro instead of gemini-1.5-pro. The old model was removed from model_prices JSON, causing supports_system_messages to return False, which prevented system_instruction from appearing in the transformation output. Co-authored-by: yuneng-jiang <yuneng-jiang@users.noreply.github.com>
This commit is contained in:
co-authored by
yuneng-jiang
parent
cc3f9cd65b
commit
9a356644bf
@@ -1932,16 +1932,16 @@ def test_transform_request_uses_dynamic_max_tokens():
|
||||
|
||||
messages = [{"role": "user", "content": "Hello"}]
|
||||
|
||||
# Claude 3.5 model should get 8192 as default max_tokens
|
||||
# Claude 3.7 model should get 64000 as default max_tokens (from model_prices_and_context_window.json)
|
||||
result = config.transform_request(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
model="claude-3-7-sonnet-20250219",
|
||||
messages=messages,
|
||||
optional_params={}, # No max_tokens provided
|
||||
litellm_params={},
|
||||
headers={}
|
||||
)
|
||||
|
||||
assert result["max_tokens"] == 8192
|
||||
assert result["max_tokens"] == 64000
|
||||
|
||||
|
||||
def test_transform_request_respects_user_max_tokens():
|
||||
@@ -1955,7 +1955,7 @@ def test_transform_request_respects_user_max_tokens():
|
||||
|
||||
# User provides explicit max_tokens=1000, should not be overridden
|
||||
result = config.transform_request(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
model="claude-3-7-sonnet-20250219",
|
||||
messages=messages,
|
||||
optional_params={"max_tokens": 1000},
|
||||
litellm_params={},
|
||||
|
||||
@@ -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-2.5-pro",
|
||||
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-2.5-pro"
|
||||
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-2.5-pro"
|
||||
|
||||
|
||||
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-2.5-pro",
|
||||
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-2.5-pro"
|
||||
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-2.5-pro"
|
||||
|
||||
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-2.5-pro",
|
||||
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-2.5-pro"
|
||||
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-2.5-pro"
|
||||
|
||||
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-2.5-pro",
|
||||
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-2.5-pro"
|
||||
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-2.5-pro"
|
||||
|
||||
assert result["displayName"] == "test-cache-key"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user