From c83498f0cd87307b4dce9fa7d531ae739fac97ed Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Fri, 7 Feb 2025 22:45:45 -0800 Subject: [PATCH] Litellm dev 02 07 2025 p3 (#8387) * add back streaming for base o3 (#8361) * test(base_llm_unit_tests.py): add base test for o-series models - ensure streaming always works * fix(base_llm_unit_tests.py): fix test for o series models * refactor: move test --------- Co-authored-by: Matteo Boschini <12133566+mbosc@users.noreply.github.com> --- .../openai/chat/o_series_transformation.py | 2 +- tests/llm_translation/test_openai_o1.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/litellm/llms/openai/chat/o_series_transformation.py b/litellm/llms/openai/chat/o_series_transformation.py index d643b07680..3cc05b3c95 100644 --- a/litellm/llms/openai/chat/o_series_transformation.py +++ b/litellm/llms/openai/chat/o_series_transformation.py @@ -54,7 +54,7 @@ class OpenAIOSeriesConfig(OpenAIGPTConfig): if model is None: return True - supported_stream_models = ["o1-mini", "o1-preview"] + supported_stream_models = ["o1-mini", "o1-preview", "o3-mini"] for supported_model in supported_stream_models: if supported_model in model: return False diff --git a/tests/llm_translation/test_openai_o1.py b/tests/llm_translation/test_openai_o1.py index c4eec4ca5f..16b86414c2 100644 --- a/tests/llm_translation/test_openai_o1.py +++ b/tests/llm_translation/test_openai_o1.py @@ -204,3 +204,26 @@ def test_o3_reasoning_effort(): reasoning_effort="high", ) assert resp.choices[0].message.content is not None + + +def test_streaming_response(): + """Test that streaming response is returned correctly""" + from litellm import completion + + response = completion( + model="o3-mini", + messages=[ + {"role": "system", "content": "Be a good bot!"}, + {"role": "user", "content": "Hello!"}, + ], + stream=True, + ) + + assert response is not None + + chunks = [] + for chunk in response: + chunks.append(chunk) + + resp = litellm.stream_chunk_builder(chunks=chunks) + print(resp)