From fd2104a61efe91eb1428d40c3261527c363ea5d6 Mon Sep 17 00:00:00 2001 From: mateo-berri Date: Thu, 3 Sep 2026 00:27:54 -0700 Subject: [PATCH] refactor(oci): build the identity-pinned stream chunk in one shot Address the two Greptile P2 notes: construct the chunk through the shared creator instead of mutating its choices afterwards, and drop the decorative divider comment from the new tests. --- litellm/llms/oci/chat/transformation.py | 4 +--- .../llms/oci/chat/test_oci_chat_transformation.py | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/litellm/llms/oci/chat/transformation.py b/litellm/llms/oci/chat/transformation.py index 17aed74b9d3..b1167d447fc 100644 --- a/litellm/llms/oci/chat/transformation.py +++ b/litellm/llms/oci/chat/transformation.py @@ -746,9 +746,7 @@ class OCIStreamWrapper(CustomStreamWrapper): self._cohere_text_emitted = False def _with_stream_identity(self, parsed: ModelResponseStream) -> ModelResponseStream: - model_response: Final = self.model_response_creator() - model_response.choices = parsed.choices - return model_response + return self.model_response_creator(chunk={"choices": parsed.choices}) def chunk_creator(self, chunk: Any) -> ModelResponseStream | None: if not isinstance(chunk, str): diff --git a/tests/test_litellm/llms/oci/chat/test_oci_chat_transformation.py b/tests/test_litellm/llms/oci/chat/test_oci_chat_transformation.py index 6601de2853d..e77b2c24d01 100644 --- a/tests/test_litellm/llms/oci/chat/test_oci_chat_transformation.py +++ b/tests/test_litellm/llms/oci/chat/test_oci_chat_transformation.py @@ -1902,10 +1902,6 @@ class TestOCIImageUrlTransformation: assert "image_url" in str(exc_info.value) -# --------------------------------------------------------------------------- -# OCIStreamWrapper: per-stream identity and the GENERIC `[DONE]` sentinel -# --------------------------------------------------------------------------- - import itertools from unittest.mock import patch