async def test_stream_retry_on_exception(self, mock_sleep):
        """Ensures that _stream retries on exceptions and raises after retries exhausted."""
        payload = {"prompt": "Hello"}

        # Define an async context manager that raises an exception
        @asynccontextmanager
        async def stream_context_manager(*args, **kwargs):
            raise httpx.RequestError("Connection error")
            yield  # This is never reached

        # Mock the stream method to use our context manager
        self.client._client.stream = Mock(side_effect=stream_context_manager)

        with pytest.raises(ExtendedRequestException):
            async for _ in self.client._stream(payload):
                pass

        assert (
            self.client._client.stream.call_count == self.retries + 1
        )  # initial attempt + retries
Ensures that _stream retries on exceptions and raises after retries exhausted.
llama-index-integrations/llms/llama-index-llms-oci-data-science/tests/test_oci_data_science_client.py