This commit is contained in:
yuneng-jiang 2026-10-04 07:44:39 -07:00 • committed by GitHub
commit b49a0b7be6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1343,12 +1343,13 @@ def test_is_prompt_caching_enabled_error_handling():
def test_is_prompt_caching_enabled_return_default_image_dimensions():
"""
Assert that `is_prompt_caching_valid_prompt` calls token_counter with use_default_image_token_count=True
Assert that `is_prompt_caching_valid_prompt` counts tokens with use_default_image_token_count=True
when processing messages containing images
IMPORTANT: Ensures Get token counter does not make a GET request to the image url
"""
with patch("litellm.utils.token_counter") as mock_token_counter:
mock_token_counter = MagicMock(return_value=False)
with patch("litellm.utils._get_messages_reach_token_count", return_value=mock_token_counter):
litellm.utils.is_prompt_caching_valid_prompt(
messages=[
{
@ -1370,7 +1371,6 @@ def test_is_prompt_caching_enabled_return_default_image_dimensions():
model="gpt-4o-mini",
)
# Assert token_counter was called with use_default_image_token_count=True
args_to_mock_token_counter = mock_token_counter.call_args[1]
print("args_to_mock", args_to_mock_token_counter)
assert args_to_mock_token_counter["use_default_image_token_count"] is True