From d94cff55ff686f1ae82f452f33c6a041d785dcb3 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 26 Feb 2025 08:13:12 -0800 Subject: [PATCH] test_prompt_caching --- tests/llm_translation/base_llm_unit_tests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.py index b53a642e6a..ad7dd9e1d1 100644 --- a/tests/llm_translation/base_llm_unit_tests.py +++ b/tests/llm_translation/base_llm_unit_tests.py @@ -6,6 +6,7 @@ from typing import Any, Dict, List from unittest.mock import MagicMock, Mock, patch import os import uuid +import time sys.path.insert( 0, os.path.abspath("../..") @@ -600,6 +601,8 @@ class BaseLLMChatTest(ABC): max_tokens=10, ) + time.sleep(1) + cached_cost = response._hidden_params["response_cost"] assert ( @@ -616,7 +619,9 @@ class BaseLLMChatTest(ABC): _usage_format_tests(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: pass