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

        # Mock the exception to be raised
        def side_effect(*args, **kwargs):
            raise httpx.RequestError("Connection error")

        # Mock the context manager
        self.client._client.stream.side_effect = side_effect

        with pytest.raises(ExtendedRequestException):
            list(self.client._stream(payload))

        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