Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test_prompt_caching

Ishaan Jaff56b257697951
diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.py
index b53a642e6ab..ad7dd9e1d1f 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