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]

add testing for test_anthropic_cache_controls_pt

Ishaan Jaff9791352dc682
diff --git a/litellm/tests/test_prompt_factory.py b/litellm/tests/test_prompt_factory.py
index 2351e2c121c..93e92a7926a 100644
--- a/litellm/tests/test_prompt_factory.py
+++ b/litellm/tests/test_prompt_factory.py
@@ -263,6 +263,7 @@ def test_anthropic_messages_tool_call():
def test_anthropic_cache_controls_pt():
+ "see anthropic docs for this: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#continuing-a-multi-turn-conversation"
messages = [
# marked for caching with the cache_control parameter, so that this checkpoint can read from the previous cache.
{
@@ -290,6 +291,11 @@ def test_anthropic_cache_controls_pt():
}
],
},
+ {
+ "role": "assistant",
+ "content": "Certainly! the key terms and conditions are the following: the contract is 1 year long for $10/mo",
+ "cache_control": {"type": "ephemeral"},
+ },
]
translated_messages = anthropic_messages_pt(
@@ -303,5 +309,7 @@ def test_anthropic_cache_controls_pt():
assert "cache_controls" not in msg["content"][0]
elif i == 2:
assert msg["content"][0]["cache_control"] == {"type": "ephemeral"}
+ elif i == 3:
+ assert msg["content"][0]["cache_control"] == {"type": "ephemeral"}
print("translated_messages: ", translated_messages)