From 686556fffc475a0ae083286440b50bba771da26c Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Sep 2026 17:49:15 +0000 Subject: [PATCH] test(anthropic): build served-model stream chunks immutably Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../chat/test_anthropic_chat_handler.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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,