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(anthropic): build served-model stream chunks immutably

kerry686556fffc47
diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_handler.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_handler.py
index 7db44b4709e..a241fc03d57 100644
--- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_handler.py
+++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_handler.py
@@ -2721,18 +2721,19 @@ class TestRustChatCompletionsHook:
}
-def _served_model_stream_chunks(model: str | None) -> list[dict]:
- message: Final = {
- "id": "msg_served",
- "type": "message",
- "role": "assistant",
- "content": [],
- "usage": {"input_tokens": 10, "output_tokens": 1},
- }
- if model is not None:
- message["model"] = model
+def _served_model_stream_chunks(model: str | None) -> list[dict[str, object]]:
return [
- {"type": "message_start", "message": message},
+ {
+ "type": "message_start",
+ "message": {
+ "id": "msg_served",
+ "type": "message",
+ "role": "assistant",
+ "content": [],
+ "usage": {"input_tokens": 10, "output_tokens": 1},
+ **({"model": model} if model is not None else {}),
+ },
+ },
{
"type": "content_block_start",
"index": 0,