test_prompt_caching

This commit is contained in:
Ishaan Jaff 2025-02-26 08:13:12 -08:00 committed by Krrish Dholakia
parent 49c5e7811e
commit d94cff55ff

View file

@ -6,6 +6,7 @@ from typing import Any, Dict, List
from unittest.mock import MagicMock, Mock, patch from unittest.mock import MagicMock, Mock, patch
import os import os
import uuid import uuid
import time
sys.path.insert( sys.path.insert(
0, os.path.abspath("../..") 0, os.path.abspath("../..")
@ -600,6 +601,8 @@ class BaseLLMChatTest(ABC):
max_tokens=10, max_tokens=10,
) )
time.sleep(1)
cached_cost = response._hidden_params["response_cost"] cached_cost = response._hidden_params["response_cost"]
assert ( assert (
@ -616,7 +619,9 @@ class BaseLLMChatTest(ABC):
_usage_format_tests(response.usage) _usage_format_tests(response.usage)
assert "prompt_tokens_details" in response.usage assert "prompt_tokens_details" in response.usage
assert response.usage.prompt_tokens_details.cached_tokens > 0 assert (
response.usage.prompt_tokens_details.cached_tokens > 0
), f"cached_tokens={response.usage.prompt_tokens_details.cached_tokens} should be greater than 0. Got usage={response.usage}"
except litellm.InternalServerError: except litellm.InternalServerError:
pass pass