def _parse_streaming_line(
        self, line: Union[bytes, str]
    ) -> Optional[Dict[str, Any]]:
        """
        Parse a single line from the streaming response.

        Args:
            line (Union[bytes, str]): A line of the response in bytes or string format.

        Returns:
            Optional[Dict[str, Any]]: Parsed JSON object, or None if the line is to be ignored.

        Raises:
            Exception: Raised if the line contains an error object.
            json.JSONDecodeError: Raised if the line cannot be decoded as JSON.

        """
        logger.debug(f"Parsing streaming line: {line}")

        if isinstance(line, bytes):
            line = line.decode(DEFAULT_ENCODING)

        line = line.strip()

        if line.lower().startswith("data:"):
            line = line[5:].lstrip()

        if not line or line.startswith("[DONE]"):
            logger.debug("Received end of stream signal or empty line.")
            return None

        try:
            json_line = json.loads(line)
            logger.debug(f"Parsed JSON line: {json_line}")
        except json.JSONDecodeError as e:
            logger.debug(f"Error decoding JSON from line: {line}")
            raise json.JSONDecodeError(
                f"Error decoding JSON from line: {e!s}", e.doc, e.pos
            ) from e

        if json_line.get("object") == "error":
            # Raise an error for error objects in the stream
            error_message = json_line.get("message", "Unknown error")
            logger.debug(f"Error in streaming response: {error_message}")
            raise Exception(f"Error in streaming response: {error_message}")

        return json_line

        Parse a single line from the streaming response.

        Args:
            line (Union[bytes, str]): A line of the response in bytes or string format.

        Returns:
            Optional[Dict[str, Any]]: Parsed JSON object, or None if the line is to be ignored.

        Raises:
            Exception: Raised if the line contains an error object.
            json.JSONDecodeError: Raised if the line cannot be decoded as JSON.

        
llama-index-integrations/llms/llama-index-llms-oci-data-science/llama_index/llms/oci_data_science/client.py