async def chat(
        self,
        messages: List[Dict[str, Any]],
        payload: Optional[Dict[str, Any]] = None,
        headers: Optional[Dict[str, str]] = None,
        stream: bool = False,
    ) -> Union[Dict[str, Any], AsyncIterator[Mapping[str, Any]]]:
        """
        Perform a chat interaction with the model.

        Args:
            messages (List[Dict[str, Any]]): List of message dictionaries for chat interaction.
            payload (Optional[Dict[str, Any]]): Additional parameters for the request payload.
            headers (Optional[Dict[str, str]]): HTTP headers to include in the request.
            stream (bool): Whether to use streaming for the response.

        Returns:
            Union[Dict[str, Any], AsyncIterator[Mapping[str, Any]]]: A full JSON response or an async iterator for streaming responses.

        """
        logger.debug(f"Starting chat with messages: {messages}, stream: {stream}")
        payload = {**(payload or {}), "messages": messages}
        headers = {"route": "/v1/chat/completions", **(headers or {})}
        if stream:
            return self._stream(payload=payload, headers=headers)
        return await self._request(payload=payload, headers=headers)

        Perform a chat interaction with the model.

        Args:
            messages (List[Dict[str, Any]]): List of message dictionaries for chat interaction.
            payload (Optional[Dict[str, Any]]): Additional parameters for the request payload.
            headers (Optional[Dict[str, str]]): HTTP headers to include in the request.
            stream (bool): Whether to use streaming for the response.

        Returns:
            Union[Dict[str, Any], AsyncIterator[Mapping[str, Any]]]: A full JSON response or an async iterator for streaming responses.

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