def stream_chat(
        self, messages: Sequence[ChatMessage], **kwargs: Any
    ) -> ChatResponseGen:
        """
        Stream the chat completion based on the input messages.

        Args:
            messages (Sequence[ChatMessage]): A sequence of chat messages.
            **kwargs: Additional keyword arguments.

        Yields:
            ChatResponse: The streamed chat response from the LLM.

        """
        logger.debug(f"Starting stream_chat with messages: {messages}")
        content = ""
        is_function = False
        tool_calls = []
        for response in self.client.chat(
            messages=_to_message_dicts(
                messages=messages, drop_none=kwargs.pop("drop_none", False)
            ),
            payload=self._model_kwargs(**kwargs),
            headers=self._prepare_headers(kwargs.pop("headers", {})),
            stream=True,
        ):
            logger.debug(f"Received chat chunk: {response}")
            if len(response.get("choices", [])) > 0:
                delta = response["choices"][0].get("delta") or {}
            else:
                delta = {}

            # Check if this chunk is the start of a function call
            if delta.get("tool_calls"):
                is_function = True

            # Update using deltas
            role = delta.get("role") or MessageRole.ASSISTANT
            content_delta = delta.get("content") or ""
            content += content_delta

            additional_kwargs = {}
            if is_function:
                tool_calls = _update_tool_calls(tool_calls, delta.get("tool_calls"))
                if tool_calls:
                    additional_kwargs["tool_calls"] = tool_calls

            yield ChatResponse(
                message=ChatMessage(
                    role=role,
                    content=content,
                    additional_kwargs=additional_kwargs,
                ),
                delta=content_delta,
                raw=response,
                additional_kwargs=_get_response_token_counts(response),
            )

        Stream the chat completion based on the input messages.

        Args:
            messages (Sequence[ChatMessage]): A sequence of chat messages.
            **kwargs: Additional keyword arguments.

        Yields:
            ChatResponse: The streamed chat response from the LLM.

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