From 5495003e60589c19b55214af0501abe2725e5234 Mon Sep 17 00:00:00 2001 From: Chesars Date: Mon, 2 Mar 2026 17:19:40 -0300 Subject: [PATCH] fix: add missing Dict/Optional imports in ChatGPT streaming_utils Fixes NameError at runtime when ChatGPTToolCallNormalizer is instantiated. The imports were missed when type hints were changed from Python 3.10+ syntax (dict[], str | None) to typing module syntax (Dict[], Optional[str]). --- litellm/llms/chatgpt/chat/streaming_utils.py | 2 +- tests/test_litellm/litellm_core_utils/test_streaming_handler.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/llms/chatgpt/chat/streaming_utils.py b/litellm/llms/chatgpt/chat/streaming_utils.py index 730becb06e6..3232b452a37 100644 --- a/litellm/llms/chatgpt/chat/streaming_utils.py +++ b/litellm/llms/chatgpt/chat/streaming_utils.py @@ -4,7 +4,7 @@ Streaming utilities for ChatGPT provider. Normalizes non-spec-compliant tool_call chunks from the ChatGPT backend API. """ -from typing import Any +from typing import Any, Dict, Optional class ChatGPTToolCallNormalizer: diff --git a/tests/test_litellm/litellm_core_utils/test_streaming_handler.py b/tests/test_litellm/litellm_core_utils/test_streaming_handler.py index 153ca5d5aab..72a7c6fc9a1 100644 --- a/tests/test_litellm/litellm_core_utils/test_streaming_handler.py +++ b/tests/test_litellm/litellm_core_utils/test_streaming_handler.py @@ -1274,6 +1274,7 @@ def test_usage_chunk_after_finish_reason_updates_hidden_params(logging_obj): assert hidden_usage.completion_tokens == 135, ( f"Expected completion_tokens=135 from provider, got {hidden_usage.completion_tokens}" ) + @pytest.mark.asyncio async def test_custom_stream_wrapper_aclose(): """Test that aclose() delegates to the underlying completion_stream's aclose()"""