From 6322aef0e306d369039e608234dec45e2a87cd52 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 16 Aug 2025 14:25:29 -0700 Subject: [PATCH 1/2] fix(streaming_handler.py): fix streaming chunk calculation --- litellm/litellm_core_utils/streaming_handler.py | 6 ++++++ tests/local_testing/test_custom_callback_input.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 1b6036fef86..b9433239271 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -1747,6 +1747,11 @@ class CustomStreamWrapper: if is_empty: continue print_verbose(f"final returned processed chunk: {processed_chunk}") + + # add usage as hidden param + if self.sent_last_chunk is True and self.stream_options is None: + usage = calculate_total_usage(chunks=self.chunks) + processed_chunk._hidden_params["usage"] = usage return processed_chunk raise StopAsyncIteration else: # temporary patch for non-aiohttp async calls @@ -1790,6 +1795,7 @@ class CustomStreamWrapper: messages=self.messages, logging_obj=self.logging_obj, ) + response = self.model_response_creator() if complete_streaming_response is not None: setattr( diff --git a/tests/local_testing/test_custom_callback_input.py b/tests/local_testing/test_custom_callback_input.py index 9cc41869fed..5da87d2be60 100644 --- a/tests/local_testing/test_custom_callback_input.py +++ b/tests/local_testing/test_custom_callback_input.py @@ -1599,7 +1599,7 @@ def test_logging_key_masking_gemini(): assert "PART" == trimmed_key -@pytest.mark.parametrize("sync_mode", [True]) +@pytest.mark.parametrize("sync_mode", [True, False]) @pytest.mark.asyncio async def test_standard_logging_payload_stream_usage(sync_mode): """ From e035efeec7bfd534fbf02f2b42b41f8b3eb9c28f Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 16 Aug 2025 14:30:26 -0700 Subject: [PATCH 2/2] fix(public_model_hub.tsx): fix ui --- .../src/components/public_model_hub.tsx | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ui/litellm-dashboard/src/components/public_model_hub.tsx b/ui/litellm-dashboard/src/components/public_model_hub.tsx index 9145fec4b54..4c155173760 100644 --- a/ui/litellm-dashboard/src/components/public_model_hub.tsx +++ b/ui/litellm-dashboard/src/components/public_model_hub.tsx @@ -18,6 +18,7 @@ import { EndpointType, getEndpointType } from "./chat_ui/mode_endpoint_mapping"; import { MessageType } from "./chat_ui/types"; import { getProviderLogoAndName } from "./provider_info_helpers"; import Navbar from "./navbar"; +import { ThemeProvider } from "@/contexts/ThemeContext"; // Simple approach without react-markdown dependency interface ModelGroupInfo { @@ -476,18 +477,19 @@ const PublicModelHub: React.FC = ({ accessToken }) => { ]; return ( -
- {/* Navigation */} - + +
+ {/* Navigation */} +
{/* About Section */} @@ -856,7 +858,8 @@ const PublicModelHub: React.FC = ({ accessToken }) => {
)} -
+
+ ); };